Commit 089b6bd2 by Maurits van Beusekom Committed by GitHub

Merge pull request #598 from Baseflow/issue/597

Fix deprecation warning on iOS using phone permissions.
parents 72d3dde2 639350e7
## 8.1.1
* Fixed deprecation issue when checking phone capabilities on iOS (see issue [#597](https://github.com/Baseflow/flutter-permission-handler/issues/597)).
## 8.1.0 ## 8.1.0
* Added support for iOS 12+ Critical Alerts permission requesting. * Added support for iOS 12+ Critical Alerts permission requesting.
......
...@@ -355,6 +355,7 @@ ...@@ -355,6 +355,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 7624MWN53C;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
...@@ -491,6 +492,7 @@ ...@@ -491,6 +492,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 7624MWN53C;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
...@@ -521,6 +523,7 @@ ...@@ -521,6 +523,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 7624MWN53C;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
......
...@@ -114,23 +114,27 @@ class _PermissionState extends State<PermissionWidget> { ...@@ -114,23 +114,27 @@ class _PermissionState extends State<PermissionWidget> {
_permissionStatus.toString(), _permissionStatus.toString(),
style: TextStyle(color: getPermissionColor()), style: TextStyle(color: getPermissionColor()),
), ),
trailing: IconButton( trailing: (_permission is PermissionWithService)
? IconButton(
icon: const Icon( icon: const Icon(
Icons.info, Icons.info,
color: Colors.white, color: Colors.white,
), ),
onPressed: () { onPressed: () {
checkServiceStatus(context, _permission); checkServiceStatus(
}), context, _permission as PermissionWithService);
})
: null,
onTap: () { onTap: () {
requestPermission(_permission); requestPermission(_permission);
}, },
); );
} }
void checkServiceStatus(BuildContext context, Permission permission) async { void checkServiceStatus(
BuildContext context, PermissionWithService permission) async {
ScaffoldMessenger.of(context).showSnackBar(SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text((await permission.status).toString()), content: Text((await permission.serviceStatus).toString()),
)); ));
} }
......
...@@ -30,15 +30,30 @@ ...@@ -30,15 +30,30 @@
} }
// https://stackoverflow.com/a/11595365 /**
-(bool) canDevicePlaceAPhoneCall { * Returns YES if the device can place a phone call.
/*
* Returns YES if the device can place a phone call
*/ */
-(bool) canDevicePlaceAPhoneCall {
// Device supports phone calls, lets confirm it can place one right now
CTTelephonyNetworkInfo *netInfo = [[CTTelephonyNetworkInfo alloc] init]; CTTelephonyNetworkInfo *netInfo = [[CTTelephonyNetworkInfo alloc] init];
if(@available(iOS 12.0, *)) {
NSDictionary<NSString *, CTCarrier *> *providers = [netInfo serviceSubscriberCellularProviders];
for (NSString *key in providers) {
CTCarrier *carrier = [providers objectForKey:key];
if ([self canPlacePhoneCallWithCarrier:carrier]) {
return YES;
}
}
return NO;
} else {
CTCarrier *carrier = [netInfo subscriberCellularProvider]; CTCarrier *carrier = [netInfo subscriberCellularProvider];
return [self canPlacePhoneCallWithCarrier:carrier];
}
}
-(bool)canPlacePhoneCallWithCarrier:(CTCarrier *)carrier {
// https://stackoverflow.com/a/11595365
NSString *mnc = [carrier mobileNetworkCode]; NSString *mnc = [carrier mobileNetworkCode];
if (([mnc length] == 0) || ([mnc isEqualToString:@"65535"])) { if (([mnc length] == 0) || ([mnc isEqualToString:@"65535"])) {
// Device cannot place a call at this time. SIM might be removed. // Device cannot place a call at this time. SIM might be removed.
......
name: permission_handler name: permission_handler
description: Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions. description: Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.
version: 8.1.0 version: 8.1.1
homepage: https://github.com/baseflowit/flutter-permission-handler homepage: https://github.com/baseflowit/flutter-permission-handler
flutter: flutter:
......
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