forked from Baseflow/flutter-permission-handler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
157 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// PhonePermissionStrategy.h | ||
// permission_handler | ||
// | ||
// Created by Sebastian Roth on 5/20/19. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "PermissionStrategy.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface PhonePermissionStrategy : NSObject<PermissionStrategy> | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// PhonePermissionStrategy.m | ||
// permission_handler | ||
// | ||
// Created by Sebastian Roth on 5/20/19. | ||
// | ||
|
||
#import <CoreTelephony/CTTelephonyNetworkInfo.h> | ||
#import <CoreTelephony/CTCarrier.h> | ||
|
||
#import "PhonePermissionStrategy.h" | ||
|
||
@implementation PhonePermissionStrategy | ||
|
||
- (PermissionStatus)checkPermissionStatus:(PermissionGroup)permission { | ||
return PermissionStatusUnknown; | ||
} | ||
|
||
- (ServiceStatus)checkServiceStatus:(PermissionGroup)permission { | ||
// https://stackoverflow.com/a/5095058 | ||
if (![[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel://"]]) { | ||
return ServiceStatusNotApplicable; | ||
} | ||
|
||
return [self canDevicePlaceAPhoneCall] ? ServiceStatusEnabled : ServiceStatusDisabled; | ||
} | ||
|
||
- (void)requestPermission:(PermissionGroup)permission completionHandler:(PermissionStatusHandler)completionHandler { | ||
completionHandler(PermissionStatusUnknown); | ||
} | ||
|
||
|
||
// https://stackoverflow.com/a/11595365 | ||
-(bool) canDevicePlaceAPhoneCall { | ||
/* | ||
* Returns YES if the device can place a phone call | ||
*/ | ||
|
||
// Device supports phone calls, lets confirm it can place one right now | ||
CTTelephonyNetworkInfo *netInfo = [[CTTelephonyNetworkInfo alloc] init]; | ||
CTCarrier *carrier = [netInfo subscriberCellularProvider]; | ||
NSString *mnc = [carrier mobileNetworkCode]; | ||
if (([mnc length] == 0) || ([mnc isEqualToString:@"65535"])) { | ||
// Device cannot place a call at this time. SIM might be removed. | ||
return NO; | ||
} else { | ||
// Device can place a phone call | ||
return YES; | ||
} | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.