Commit 3c78c95c by Maurits van Beusekom

Fix deprecation issue

parent 72d3dde2
...@@ -13,40 +13,55 @@ ...@@ -13,40 +13,55 @@
@implementation PhonePermissionStrategy @implementation PhonePermissionStrategy
- (PermissionStatus)checkPermissionStatus:(PermissionGroup)permission { - (PermissionStatus)checkPermissionStatus:(PermissionGroup)permission {
return PermissionStatusDenied; return PermissionStatusDenied;
} }
- (ServiceStatus)checkServiceStatus:(PermissionGroup)permission { - (ServiceStatus)checkServiceStatus:(PermissionGroup)permission {
// https://stackoverflow.com/a/5095058 // https://stackoverflow.com/a/5095058
if (![[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel://"]]) { if (![[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel://"]]) {
return ServiceStatusNotApplicable; return ServiceStatusNotApplicable;
} }
return [self canDevicePlaceAPhoneCall] ? ServiceStatusEnabled : ServiceStatusDisabled; return [self canDevicePlaceAPhoneCall] ? ServiceStatusEnabled : ServiceStatusDisabled;
} }
- (void)requestPermission:(PermissionGroup)permission completionHandler:(PermissionStatusHandler)completionHandler { - (void)requestPermission:(PermissionGroup)permission completionHandler:(PermissionStatusHandler)completionHandler {
completionHandler(PermissionStatusPermanentlyDenied); completionHandler(PermissionStatusPermanentlyDenied);
} }
// https://stackoverflow.com/a/11595365 /**
* Returns YES if the device can place a phone call.
*/
-(bool) canDevicePlaceAPhoneCall { -(bool) canDevicePlaceAPhoneCall {
/* CTTelephonyNetworkInfo *netInfo = [[CTTelephonyNetworkInfo alloc] init];
* Returns YES if the device can place a phone call
*/ if(@available(iOS 12.0, *)) {
NSDictionary<NSString *, CTCarrier *> *providers = [netInfo serviceSubscriberCellularProviders];
// Device supports phone calls, lets confirm it can place one right now for (NSString *key in providers) {
CTTelephonyNetworkInfo *netInfo = [[CTTelephonyNetworkInfo alloc] init]; CTCarrier *carrier = [providers objectForKey:key];
CTCarrier *carrier = [netInfo subscriberCellularProvider]; if ([self canPlacePhoneCallWithCarrier:carrier]) {
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; return YES;
}
} }
return NO;
} else {
CTCarrier *carrier = [netInfo subscriberCellularProvider];
return [self canPlacePhoneCallWithCarrier:carrier];
}
}
-(bool)canPlacePhoneCallWithCarrier:(CTCarrier *)carrier {
// https://stackoverflow.com/a/11595365
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 @end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment