diff --git a/permission_handler_apple/CHANGELOG.md b/permission_handler_apple/CHANGELOG.md index fbd51929f..6aeb8649e 100644 --- a/permission_handler_apple/CHANGELOG.md +++ b/permission_handler_apple/CHANGELOG.md @@ -1,3 +1,7 @@ +## 9.4.8 + +* Rewrite copyleft code from stackoverflow to fix compliance issue. + ## 9.4.7 * Increases minimum supported Flutter version to 3.3.0, and removes code only diff --git a/permission_handler_apple/ios/Classes/strategies/PhonePermissionStrategy.m b/permission_handler_apple/ios/Classes/strategies/PhonePermissionStrategy.m index 37222849d..7223f188e 100644 --- a/permission_handler_apple/ios/Classes/strategies/PhonePermissionStrategy.m +++ b/permission_handler_apple/ios/Classes/strategies/PhonePermissionStrategy.m @@ -17,8 +17,9 @@ - (PermissionStatus)checkPermissionStatus:(PermissionGroup)permission { } - (void)checkServiceStatus:(PermissionGroup)permission completionHandler:(ServiceStatusHandler)completionHandler { - // https://stackoverflow.com/a/5095058 - if (![[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel://"]]) { + UIApplication *app = [UIApplication sharedApplication]; + NSURL *telURL = [NSURL URLWithString:@"tel://"]; + if (![app canOpenURL:telURL]) { completionHandler(ServiceStatusNotApplicable); } completionHandler([self canDevicePlaceAPhoneCall] ? ServiceStatusEnabled : ServiceStatusDisabled); @@ -52,15 +53,14 @@ -(bool) canDevicePlaceAPhoneCall { } -(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; + NSString *networkCode = [carrier mobileNetworkCode]; + if (networkCode.length == 0 || [networkCode isEqualToString:@"65535"]) { + // Device is unable to initiate a call at this time. SIM might be missing. + return NO; } + + // Mobile Network Code is valid and device can initiate a call + return YES; } @end diff --git a/permission_handler_apple/pubspec.yaml b/permission_handler_apple/pubspec.yaml index 4abd13fb3..496e1aca6 100644 --- a/permission_handler_apple/pubspec.yaml +++ b/permission_handler_apple/pubspec.yaml @@ -2,7 +2,7 @@ name: permission_handler_apple description: Permission plugin for Flutter. This plugin provides the iOS API to request and check permissions. repository: https://github.com/baseflow/flutter-permission-handler issue_tracker: https://github.com/Baseflow/flutter-permission-handler/issues -version: 9.4.7 +version: 9.4.8 environment: sdk: ">=2.18.0 <4.0.0"