@@ -5,13 +5,9 @@ import { checkAndRequestNotificationAccessSpecialPermission, checkNotificationAc
55export const requestGrantPermissions = async ( ) => {
66 // Request permissions on Android
77 if ( Platform . OS === 'android' && Platform . Version >= 23 ) {
8- PermissionsAndroid . requestMultiple ( getAndroidPermissions ( ) ) . then ( async ( result ) => {
8+ return PermissionsAndroid . requestMultiple ( getAndroidPermissions ( ) ) . then ( async ( result ) => {
99 console . log ( 'Permissions granted:' , result ) ;
1010
11- //if (await checkNotificationPermission() && !(await NotificationService.isNotificationListenerEnabled())) {
12- // await NotificationService.startNotificationListenerService()
13- //}
14-
1511 const allGranted = Object . values ( result ) . every (
1612 ( value ) => value === PermissionsAndroid . RESULTS . GRANTED
1713 ) ;
@@ -21,21 +17,30 @@ export const requestGrantPermissions = async () => {
2117 // Optionally handle partial denial here
2218 await displayPermissionDeniedWarning ( ) ;
2319 }
20+ return allGranted ;
2421 } )
2522 . catch ( ( error ) => {
2623 console . error ( 'Error requesting permissions:' , error ) ;
24+ return false ;
2725 } ) ;
2826 }
27+ return true ;
2928} ;
3029
31- export const displayPermissionDeniedWarning = async ( ) => {
32- Alert . alert (
33- 'Permissions Required' ,
34- 'Some permissions were denied. Please go to Settings and enable all required permissions for the app to function properly.' ,
35- [
36- { text : 'OK' , style : 'default' } ,
37- ]
38- ) ;
30+ export const displayPermissionDeniedWarning = ( ) => {
31+ return new Promise ( ( resolve ) => {
32+ Alert . alert (
33+ 'Permissions Required' ,
34+ 'Some permissions were denied. Please go to Settings and enable all required permissions for the app to function properly.' ,
35+ [
36+ {
37+ text : 'OK' ,
38+ style : 'default' ,
39+ onPress : ( ) => resolve ( true )
40+ } ,
41+ ]
42+ ) ;
43+ } ) ;
3944} ;
4045
4146export const doesHaveAllPermissions = async ( ) => {
@@ -48,11 +53,8 @@ export const doesHaveAllPermissions = async () => {
4853 }
4954 }
5055
51- try {
52- await checkAndRequestNotificationAccessSpecialPermission ( ) ;
53- } catch ( error ) {
54- console . warn ( 'Notification permission request error:' , error ) ;
55- }
56+ let notificationPerms = await checkNotificationAccessSpecialPermission ( ) ;
57+ if ( ! notificationPerms ) allGranted = false ;
5658
5759 return allGranted ;
5860 } else if ( Platform . OS === 'ios' ) {
@@ -65,6 +67,10 @@ export const doesHaveAllPermissions = async () => {
6567export const getAndroidPermissions = ( ) : Permission [ ] => {
6668 const list = [ ] ;
6769 if ( Platform . OS === 'android' ) {
70+ if ( Platform . Version < 29 ) {
71+ list . push ( PermissionsAndroid . PERMISSIONS . WRITE_EXTERNAL_STORAGE ) ;
72+ }
73+
6874 if ( Platform . Version >= 23 ) {
6975 list . push ( PermissionsAndroid . PERMISSIONS . ACCESS_FINE_LOCATION ) ;
7076 }
@@ -75,7 +81,14 @@ export const getAndroidPermissions = (): Permission[] => {
7581 }
7682 if ( Platform . Version >= 33 ) {
7783 list . push ( PermissionsAndroid . PERMISSIONS . POST_NOTIFICATIONS ) ;
84+ } else {
85+ list . push ( PermissionsAndroid . PERMISSIONS . READ_EXTERNAL_STORAGE ) ;
7886 }
87+
88+ list . push ( PermissionsAndroid . PERMISSIONS . READ_CALENDAR ) ;
89+ list . push ( PermissionsAndroid . PERMISSIONS . WRITE_CALENDAR ) ;
90+ list . push ( PermissionsAndroid . PERMISSIONS . RECORD_AUDIO ) ;
91+ list . push ( PermissionsAndroid . PERMISSIONS . POST_NOTIFICATIONS ) ;
7992 }
8093 return list as Permission [ ] ;
8194}
0 commit comments