Skip to content

Commit bae50ea

Browse files
authored
Fix: permissions related issues for both Platforms (CCExtractor#499)
* fix: setup notification permission ios * fix: add platform check for permissions related to Android only
1 parent f35c586 commit bae50ea

File tree

6 files changed

+65
-40
lines changed

6 files changed

+65
-40
lines changed

ios/Podfile

+12
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,17 @@ end
3737
post_install do |installer|
3838
installer.pods_project.targets.each do |target|
3939
flutter_additional_ios_build_settings(target)
40+
41+
target.build_configurations.each do |config|
42+
# You can remove unused permissions here
43+
# for more infomation: https://github.com/BaseflowIT/flutter-permission-handler/blob/master/permission_handler/ios/Classes/PermissionHandlerEnums.h
44+
# e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0'
45+
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
46+
'$(inherited)',
47+
48+
## dart: PermissionGroup.notification
49+
'PERMISSION_NOTIFICATIONS=1',
50+
]
51+
end
4052
end
4153
end

ios/Podfile.lock

+27-22
Original file line numberDiff line numberDiff line change
@@ -693,21 +693,21 @@ PODS:
693693
- firebase_core (2.24.2):
694694
- Firebase/CoreOnly (= 10.18.0)
695695
- Flutter
696-
- FirebaseAppCheckInterop (10.21.0)
696+
- FirebaseAppCheckInterop (10.22.0)
697697
- FirebaseCore (10.18.0):
698698
- FirebaseCoreInternal (~> 10.0)
699699
- GoogleUtilities/Environment (~> 7.12)
700700
- GoogleUtilities/Logger (~> 7.12)
701-
- FirebaseCoreExtension (10.21.0):
701+
- FirebaseCoreExtension (10.22.0):
702702
- FirebaseCore (~> 10.0)
703-
- FirebaseCoreInternal (10.21.0):
703+
- FirebaseCoreInternal (10.22.0):
704704
- "GoogleUtilities/NSData+zlib (~> 7.8)"
705705
- FirebaseFirestore (10.18.0):
706706
- FirebaseCore (~> 10.0)
707707
- FirebaseCoreExtension (~> 10.0)
708708
- FirebaseFirestoreInternal (~> 10.17)
709709
- FirebaseSharedSwift (~> 10.0)
710-
- FirebaseFirestoreInternal (10.21.0):
710+
- FirebaseFirestoreInternal (10.22.0):
711711
- abseil/algorithm (~> 1.20220623.0)
712712
- abseil/base (~> 1.20220623.0)
713713
- abseil/container/flat_hash_map (~> 1.20220623.0)
@@ -720,8 +720,8 @@ PODS:
720720
- FirebaseCore (~> 10.0)
721721
- "gRPC-C++ (~> 1.49.1)"
722722
- leveldb-library (~> 1.22)
723-
- nanopb (< 2.30910.0, >= 2.30908.0)
724-
- FirebaseSharedSwift (10.21.0)
723+
- nanopb (< 2.30911.0, >= 2.30908.0)
724+
- FirebaseSharedSwift (10.22.0)
725725
- fl_location (0.0.1):
726726
- Flutter
727727
- Flutter (1.0.0)
@@ -740,7 +740,7 @@ PODS:
740740
- Flutter
741741
- FlutterMacOS
742742
- GoogleSignIn (~> 7.0)
743-
- GoogleDataTransport (9.3.0):
743+
- GoogleDataTransport (9.4.0):
744744
- GoogleUtilities/Environment (~> 7.7)
745745
- nanopb (< 2.30910.0, >= 2.30908.0)
746746
- PromisesObjC (< 3.0, >= 1.2)
@@ -765,13 +765,18 @@ PODS:
765765
- GoogleToolboxForMac/Defines (= 2.3.2)
766766
- "GoogleToolboxForMac/NSString+URLArguments (= 2.3.2)"
767767
- "GoogleToolboxForMac/NSString+URLArguments (2.3.2)"
768-
- GoogleUtilities/Environment (7.12.0):
768+
- GoogleUtilities/Environment (7.13.0):
769+
- GoogleUtilities/Privacy
769770
- PromisesObjC (< 3.0, >= 1.2)
770-
- GoogleUtilities/Logger (7.12.0):
771+
- GoogleUtilities/Logger (7.13.0):
771772
- GoogleUtilities/Environment
772-
- "GoogleUtilities/NSData+zlib (7.12.0)"
773-
- GoogleUtilities/UserDefaults (7.12.0):
773+
- GoogleUtilities/Privacy
774+
- "GoogleUtilities/NSData+zlib (7.13.0)":
775+
- GoogleUtilities/Privacy
776+
- GoogleUtilities/Privacy (7.13.0)
777+
- GoogleUtilities/UserDefaults (7.13.0):
774778
- GoogleUtilities/Logger
779+
- GoogleUtilities/Privacy
775780
- GoogleUtilitiesComponents (1.1.0):
776781
- GoogleUtilities/Logger
777782
- "gRPC-C++ (1.49.1)":
@@ -841,7 +846,7 @@ PODS:
841846
- GTMSessionFetcher/Core (2.3.0)
842847
- isar_flutter_libs (1.0.0):
843848
- Flutter
844-
- leveldb-library (1.22.3)
849+
- leveldb-library (1.22.4)
845850
- MLImage (1.0.0-beta4)
846851
- MLKitBarcodeScanning (3.0.0):
847852
- MLKitCommon (~> 9.0)
@@ -1012,13 +1017,13 @@ SPEC CHECKSUMS:
10121017
file_picker: 15fd9539e4eb735dc54bae8c0534a7a9511a03de
10131018
Firebase: 414ad272f8d02dfbf12662a9d43f4bba9bec2a06
10141019
firebase_core: 0af4a2b24f62071f9bf283691c0ee41556dcb3f5
1015-
FirebaseAppCheckInterop: 69fc7d8f6a1cbfa973efb8d1723651de30d12525
1020+
FirebaseAppCheckInterop: 58db3e9494751399cf3e7b7e3e705cff71099153
10161021
FirebaseCore: 2322423314d92f946219c8791674d2f3345b598f
1017-
FirebaseCoreExtension: 1c044fd46e95036cccb29134757c499613f3f564
1018-
FirebaseCoreInternal: 43c1788eaeee9d1b97caaa751af567ce11010d00
1022+
FirebaseCoreExtension: 6394c00b887d0bebadbc7049c464aa0cbddc5d41
1023+
FirebaseCoreInternal: bca337352024b18424a61e478460547d46c4c753
10191024
FirebaseFirestore: 171bcbb57a1a348dd171a0d5e382c03ef85a77bb
1020-
FirebaseFirestoreInternal: 7ac1e0c5b4e75aeb898dfe4b1d6d77abbac9eca3
1021-
FirebaseSharedSwift: 19b3f709993d6fa1d84941d41c01e3c4c11eab93
1025+
FirebaseFirestoreInternal: 86fe6fc8ca156309cb4842d2d7b2f15c669a64a0
1026+
FirebaseSharedSwift: 48076404e6e52372290d15a07d2ed1d2f1754023
10221027
fl_location: 68b4a6c4aad2a453493ff66f196e0748280cf43e
10231028
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
10241029
flutter_fgbg: 31c0d1140a131daea2d342121808f6aa0dcd879d
@@ -1027,18 +1032,18 @@ SPEC CHECKSUMS:
10271032
flutter_volume_controller: e4d5832f08008180f76e30faf671ffd5a425e529
10281033
fluttertoast: 31b00dabfa7fb7bacd9e7dbee580d7a2ff4bf265
10291034
google_sign_in_ios: 1bfaf6607b44cd1b24c4d4bc39719870440f9ce1
1030-
GoogleDataTransport: 57c22343ab29bc686febbf7cbb13bad167c2d8fe
1035+
GoogleDataTransport: bed3a36c04c8552479fbb9b76326e0fc69bddcb2
10311036
GoogleMLKit: 2bd0dc6253c4d4f227aad460f69215a504b2980e
10321037
GoogleSignIn: b232380cf495a429b8095d3178a8d5855b42e842
10331038
GoogleToolboxForMac: 8bef7c7c5cf7291c687cf5354f39f9db6399ad34
1034-
GoogleUtilities: 0759d1a57ebb953965c2dfe0ba4c82e95ccc2e34
1039+
GoogleUtilities: d053d902a8edaa9904e1bd00c37535385b8ed152
10351040
GoogleUtilitiesComponents: 679b2c881db3b615a2777504623df6122dd20afe
10361041
"gRPC-C++": 2df8cba576898bdacd29f0266d5236fa0e26ba6a
10371042
gRPC-Core: a21a60aefc08c68c247b439a9ef97174b0c54f96
10381043
GTMAppAuth: 99fb010047ba3973b7026e45393f51f27ab965ae
10391044
GTMSessionFetcher: 3a63d75eecd6aa32c2fc79f578064e1214dfdec2
10401045
isar_flutter_libs: b69f437aeab9c521821c3f376198c4371fa21073
1041-
leveldb-library: e74c27d8fbd22854db7cb467968a0b8aa1db7126
1046+
leveldb-library: 06a69cc7582d64b29424a63e085e683cc188230a
10421047
MLImage: 7bb7c4264164ade9bf64f679b40fb29c8f33ee9b
10431048
MLKitBarcodeScanning: 04e264482c5f3810cb89ebc134ef6b61e67db505
10441049
MLKitCommon: c1b791c3e667091918d91bda4bba69a91011e390
@@ -1057,6 +1062,6 @@ SPEC CHECKSUMS:
10571062
url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812
10581063
vibration: 7d883d141656a1c1a6d8d238616b2042a51a1241
10591064

1060-
PODFILE CHECKSUM: 4e8f8b2be68aeea4c0d5beb6ff1e79fface1d048
1065+
PODFILE CHECKSUM: b0d4019d63a06aa0d701044dbc594a28e1b1d370
10611066

1062-
COCOAPODS: 1.14.3
1067+
COCOAPODS: 1.15.2

ios/Runner.xcodeproj/project.pbxproj

+4-2
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@
124124
EE7366E14E5A260606CB06CD /* Pods-Runner.release.xcconfig */,
125125
B33171C6E207358295CC5A05 /* Pods-Runner.profile.xcconfig */,
126126
);
127-
name = Pods;
128127
path = Pods;
129128
sourceTree = "<group>";
130129
};
@@ -160,7 +159,7 @@
160159
97C146E61CF9000F007C117D /* Project object */ = {
161160
isa = PBXProject;
162161
attributes = {
163-
LastUpgradeCheck = 1430;
162+
LastUpgradeCheck = 1510;
164163
ORGANIZATIONNAME = "";
165164
TargetAttributes = {
166165
97C146ED1CF9000F007C117D = {
@@ -381,6 +380,7 @@
381380
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
382381
CLANG_ENABLE_MODULES = YES;
383382
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
383+
DEVELOPMENT_TEAM = A36HPZ86P4;
384384
ENABLE_BITCODE = NO;
385385
INFOPLIST_FILE = Runner/Info.plist;
386386
LD_RUNPATH_SEARCH_PATHS = (
@@ -509,6 +509,7 @@
509509
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
510510
CLANG_ENABLE_MODULES = YES;
511511
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
512+
DEVELOPMENT_TEAM = A36HPZ86P4;
512513
ENABLE_BITCODE = NO;
513514
INFOPLIST_FILE = Runner/Info.plist;
514515
LD_RUNPATH_SEARCH_PATHS = (
@@ -531,6 +532,7 @@
531532
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
532533
CLANG_ENABLE_MODULES = YES;
533534
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
535+
DEVELOPMENT_TEAM = A36HPZ86P4;
534536
ENABLE_BITCODE = NO;
535537
INFOPLIST_FILE = Runner/Info.plist;
536538
LD_RUNPATH_SEARCH_PATHS = (

ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1430"
3+
LastUpgradeVersion = "1510"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

ios/Runner/Info.plist

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
4-
<dict>
4+
<dict>
5+
<key>PermissionGroupNotification</key>
6+
<string>This app needs notification permissions to show notifications.</string>
57
<key>NSCameraUsageDescription</key>
68
<string>This app needs camera access to scan QR codes</string>
79
<key>NSPhotoLibraryUsageDescription</key>

lib/app/modules/addOrUpdateAlarm/controllers/add_or_update_alarm_controller.dart

+18-14
Original file line numberDiff line numberDiff line change
@@ -193,24 +193,28 @@ class AddOrUpdateAlarmController extends GetxController {
193193
onPressed: () async {
194194
Get.back();
195195

196-
// Request overlay permission
197-
if (!(await Permission.systemAlertWindow.isGranted)) {
198-
final status = await Permission.systemAlertWindow.request();
199-
if (!status.isGranted) {
200-
debugPrint('SYSTEM_ALERT_WINDOW permission denied!');
201-
return;
196+
if (Platform.isAndroid) {
197+
// Request overlay permission
198+
if (!(await Permission.systemAlertWindow.isGranted)) {
199+
final status = await Permission.systemAlertWindow.request();
200+
if (!status.isGranted) {
201+
debugPrint('SYSTEM_ALERT_WINDOW permission denied!');
202+
return;
203+
}
202204
}
203-
}
204205

205-
if (!(await Permission.ignoreBatteryOptimizations.isGranted)) {
206-
bool requested = await Permission.ignoreBatteryOptimizations
207-
.request()
208-
.isGranted;
209-
if (!requested) {
210-
debugPrint('IGNORE_BATTERY_OPTIMIZATION permission denied!');
211-
return;
206+
if (!(await Permission.ignoreBatteryOptimizations.isGranted)) {
207+
bool requested = await Permission.ignoreBatteryOptimizations
208+
.request()
209+
.isGranted;
210+
if (!requested) {
211+
debugPrint(
212+
'IGNORE_BATTERY_OPTIMIZATION permission denied!');
213+
return;
214+
}
212215
}
213216
}
217+
214218
// Request notification permission
215219
if (!await Permission.notification.isGranted) {
216220
final status = await Permission.notification.request();

0 commit comments

Comments
 (0)