Ver código fonte

Fix ARC issues (handlers released too soon)

Mathieu Acthernoene 5 anos atrás
pai
commit
9eb1f4fdea

+ 3
- 2
ios/FaceID/RNPermissionHandlerFaceID.m Ver arquivo

45
       return resolve(RNPermissionStatusNotAvailable);
45
       return resolve(RNPermissionStatusNotAvailable);
46
     }
46
     }
47
 
47
 
48
-    if (![RNPermissions hasAlreadyBeenRequested:self]) {
48
+    if (![RNPermissions isFlaggedAsRequested:[[self class] handlerUniqueId]]) {
49
       return resolve(RNPermissionStatusNotDetermined);
49
       return resolve(RNPermissionStatusNotDetermined);
50
     }
50
     }
51
 
51
 
93
                       reply:^(__unused BOOL success, __unused NSError * _Nullable error) {}];
93
                       reply:^(__unused BOOL success, __unused NSError * _Nullable error) {}];
94
 
94
 
95
     // Hack to invalidate FaceID verification immediately after being requested
95
     // Hack to invalidate FaceID verification immediately after being requested
96
-    [self performSelector:@selector(invalidateContext) withObject:self afterDelay:0.015];
96
+    [self performSelector:@selector(invalidateContext) withObject:self afterDelay:0.05];
97
   } else {
97
   } else {
98
     resolve(RNPermissionStatusNotAvailable);
98
     resolve(RNPermissionStatusNotAvailable);
99
   }
99
   }
109
                                                   name:UIApplicationDidBecomeActiveNotification
109
                                                   name:UIApplicationDidBecomeActiveNotification
110
                                                 object:nil];
110
                                                 object:nil];
111
 
111
 
112
+  [RNPermissions flagAsRequested:[[self class] handlerUniqueId]];
112
   [self checkWithResolver:_resolve rejecter:_reject];
113
   [self checkWithResolver:_resolve rejecter:_reject];
113
 }
114
 }
114
 
115
 

+ 2
- 1
ios/LocationAlways/RNPermissionHandlerLocationAlways.m Ver arquivo

63
   _initialChangeEventFired = false;
63
   _initialChangeEventFired = false;
64
   _isWaitingDidBecomeActive = false;
64
   _isWaitingDidBecomeActive = false;
65
 
65
 
66
-  if (status == kCLAuthorizationStatusAuthorizedWhenInUse && ![RNPermissions hasAlreadyBeenRequested:self]) {
66
+  if (status == kCLAuthorizationStatusAuthorizedWhenInUse && ![RNPermissions isFlaggedAsRequested:[[self class] handlerUniqueId]]) {
67
     _isWaitingDidBecomeActive = true;
67
     _isWaitingDidBecomeActive = true;
68
 
68
 
69
     [[NSNotificationCenter defaultCenter] addObserver:self
69
     [[NSNotificationCenter defaultCenter] addObserver:self
77
 }
77
 }
78
 
78
 
79
 - (void)onAuthorizationStatus {
79
 - (void)onAuthorizationStatus {
80
+  [RNPermissions flagAsRequested:[[self class] handlerUniqueId]];
80
   [self checkWithResolver:_resolve rejecter:_reject];
81
   [self checkWithResolver:_resolve rejecter:_reject];
81
 
82
 
82
   [_locationManager setDelegate:nil];
83
   [_locationManager setDelegate:nil];

+ 3
- 1
ios/Motion/RNPermissionHandlerMotion.m Ver arquivo

38
     }
38
     }
39
   }
39
   }
40
 
40
 
41
-  if (![RNPermissions hasAlreadyBeenRequested:self]) {
41
+  if (![RNPermissions isFlaggedAsRequested:[[self class] handlerUniqueId]]) {
42
     return resolve(RNPermissionStatusNotDetermined);
42
     return resolve(RNPermissionStatusNotDetermined);
43
   }
43
   }
44
 
44
 
73
 
73
 
74
     self->_operationQueue = nil;
74
     self->_operationQueue = nil;
75
     self->_activityManager = nil;
75
     self->_activityManager = nil;
76
+
77
+    [RNPermissions flagAsRequested:[[self class] handlerUniqueId]];
76
   }];
78
   }];
77
 }
79
 }
78
 
80
 

+ 9
- 2
ios/Notifications/RNPermissionHandlerNotifications.h Ver arquivo

1
 #import "RNPermissions.h"
1
 #import "RNPermissions.h"
2
 
2
 
3
-@interface RNPermissionHandlerNotifications : NSObject<RNPermissionHandler, RNPermissionWithRequestOptions>
3
+@interface RNPermissionHandlerNotifications : NSObject
4
 
4
 
5
-- (void)getSettingsWithResolver:(void (^ _Nonnull)(NSDictionary * _Nonnull settings))resolve;
5
++ (NSString * _Nonnull)handlerUniqueId;
6
+
7
+- (void)checkWithResolver:(void (^ _Nonnull)(RNPermissionStatus status, NSDictionary * _Nonnull settings))resolve
8
+                 rejecter:(void (^ _Nonnull)(NSError * _Nonnull error))reject;
9
+
10
+- (void)requestWithResolver:(void (^ _Nonnull)(RNPermissionStatus status, NSDictionary * _Nonnull settings))resolve
11
+                   rejecter:(void (^ _Nonnull)(NSError * _Nonnull error))reject
12
+                    options:(NSArray<NSString *> * _Nonnull)options;
6
 
13
 
7
 @end
14
 @end

+ 75
- 93
ios/Notifications/RNPermissionHandlerNotifications.m Ver arquivo

5
 
5
 
6
 @interface RNPermissionHandlerNotifications()
6
 @interface RNPermissionHandlerNotifications()
7
 
7
 
8
-@property (nonatomic, strong) void (^resolve)(RNPermissionStatus status);
8
+@property (nonatomic, strong) void (^resolve)(RNPermissionStatus status, NSDictionary * _Nonnull settings);
9
 @property (nonatomic, strong) void (^reject)(NSError *error);
9
 @property (nonatomic, strong) void (^reject)(NSError *error);
10
 
10
 
11
 @end
11
 @end
12
 
12
 
13
 @implementation RNPermissionHandlerNotifications
13
 @implementation RNPermissionHandlerNotifications
14
 
14
 
15
-+ (NSArray<NSString *> * _Nonnull)usageDescriptionKeys {
16
-  return @[];
17
-}
18
-
19
 + (NSString * _Nonnull)handlerUniqueId {
15
 + (NSString * _Nonnull)handlerUniqueId {
20
   return @"ios.permission.NOTIFICATIONS";
16
   return @"ios.permission.NOTIFICATIONS";
21
 }
17
 }
22
 
18
 
23
-- (void)checkWithResolver:(void (^ _Nonnull)(RNPermissionStatus))resolve
24
-                 rejecter:(void (__unused ^ _Nonnull)(NSError * _Nonnull))reject {
19
+- (void)checkWithResolver:(void (^ _Nonnull)(RNPermissionStatus status, NSDictionary * _Nonnull settings))resolve
20
+                 rejecter:(void (^ _Nonnull)(NSError * _Nonnull error))reject {
25
   if (@available(iOS 10.0, *)) {
21
   if (@available(iOS 10.0, *)) {
26
-    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
22
+    [[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
23
+      NSMutableDictionary *result = [NSMutableDictionary new];
24
+
25
+      bool alert = settings.alertSetting == UNNotificationSettingEnabled;
26
+      bool badge = settings.badgeSetting == UNNotificationSettingEnabled;
27
+      bool sound = settings.soundSetting == UNNotificationSettingEnabled;
28
+      bool lockScreen = settings.lockScreenSetting == UNNotificationSettingEnabled;
29
+      bool carPlay = settings.carPlaySetting == UNNotificationSettingEnabled;
30
+
31
+      if (settings.alertSetting != UNNotificationSettingNotSupported)
32
+        [result setValue:@(alert) forKey:@"alert"];
33
+      if (settings.badgeSetting != UNNotificationSettingNotSupported)
34
+        [result setValue:@(badge) forKey:@"badge"];
35
+      if (settings.soundSetting != UNNotificationSettingNotSupported)
36
+        [result setValue:@(sound) forKey:@"sound"];
37
+      if (settings.lockScreenSetting != UNNotificationSettingNotSupported)
38
+        [result setValue:@(lockScreen) forKey:@"lockScreen"];
39
+      if (settings.carPlaySetting != UNNotificationSettingNotSupported)
40
+        [result setValue:@(carPlay) forKey:@"carPlay"];
41
+
42
+      if (@available(iOS 12.0, *)) {
43
+        bool criticalAlert = settings.criticalAlertSetting == UNNotificationSettingEnabled;
44
+
45
+        if (settings.criticalAlertSetting != UNNotificationSettingNotSupported)
46
+          [result setValue:@(criticalAlert) forKey:@"criticalAlert"];
47
+      }
27
 
48
 
28
-    [center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
29
       switch (settings.authorizationStatus) {
49
       switch (settings.authorizationStatus) {
30
         case UNAuthorizationStatusNotDetermined:
50
         case UNAuthorizationStatusNotDetermined:
31
 #ifdef __IPHONE_12_0
51
 #ifdef __IPHONE_12_0
32
         case UNAuthorizationStatusProvisional:
52
         case UNAuthorizationStatusProvisional:
33
 #endif
53
 #endif
34
-          return resolve(RNPermissionStatusNotDetermined);
54
+          return resolve(RNPermissionStatusNotDetermined, result);
35
         case UNAuthorizationStatusDenied:
55
         case UNAuthorizationStatusDenied:
36
-          return resolve(RNPermissionStatusDenied);
56
+          return resolve(RNPermissionStatusDenied, result);
37
         case UNAuthorizationStatusAuthorized:
57
         case UNAuthorizationStatusAuthorized:
38
-          return resolve(RNPermissionStatusAuthorized);
58
+          return resolve(RNPermissionStatusAuthorized, result);
39
       }
59
       }
40
     }];
60
     }];
41
   } else {
61
   } else {
42
     UIUserNotificationSettings *settings = [[UIApplication sharedApplication] currentUserNotificationSettings];
62
     UIUserNotificationSettings *settings = [[UIApplication sharedApplication] currentUserNotificationSettings];
63
+    UIUserNotificationType types = [settings types];
43
 
64
 
44
-    if ([settings types] != UIUserNotificationTypeNone) {
45
-      return resolve(RNPermissionStatusAuthorized);
46
-    } else if ([RNPermissions hasAlreadyBeenRequested:self]) {
47
-      return resolve(RNPermissionStatusDenied);
65
+    NSDictionary *result = @{
66
+      @"alert": @((bool)(types & UIUserNotificationTypeAlert)),
67
+      @"badge": @((bool)(types & UIUserNotificationTypeBadge)),
68
+      @"sound": @((bool)(types & UIUserNotificationTypeSound)),
69
+    };
70
+
71
+    if (types != UIUserNotificationTypeNone) {
72
+      return resolve(RNPermissionStatusAuthorized, result);
73
+    } else if ([RNPermissions isFlaggedAsRequested:[[self class] handlerUniqueId]]) {
74
+      return resolve(RNPermissionStatusDenied, result);
48
     } else {
75
     } else {
49
-      return resolve(RNPermissionStatusNotDetermined);
76
+      return resolve(RNPermissionStatusNotDetermined, result);
50
     }
77
     }
51
   }
78
   }
52
 }
79
 }
53
 
80
 
54
-- (void)requestWithResolver:(void (^ _Nonnull)(RNPermissionStatus))resolve
55
-                   rejecter:(void (^ _Nonnull)(NSError * _Nonnull))reject {
56
-  NSArray<NSString *> *options = [[NSArray alloc] initWithObjects:@"alert", @"badge", @"sound", nil];
57
-  [self requestWithResolver:resolve rejecter:reject options:options];
58
-}
59
-
60
-- (void)requestWithResolver:(void (^ _Nonnull)(RNPermissionStatus))resolve
61
-                   rejecter:(void (^ _Nonnull)(NSError * _Nonnull))reject
81
+- (void)requestWithResolver:(void (^ _Nonnull)(RNPermissionStatus status, NSDictionary * _Nonnull settings))resolve
82
+                   rejecter:(void (^ _Nonnull)(NSError * _Nonnull error))reject
62
                     options:(NSArray<NSString *> * _Nonnull)options {
83
                     options:(NSArray<NSString *> * _Nonnull)options {
84
+  _resolve = resolve;
85
+  _reject = reject;
86
+
63
   bool alert = [options containsObject:@"alert"];
87
   bool alert = [options containsObject:@"alert"];
64
   bool badge = [options containsObject:@"badge"];
88
   bool badge = [options containsObject:@"badge"];
65
   bool sound = [options containsObject:@"sound"];
89
   bool sound = [options containsObject:@"sound"];
86
       types += UNAuthorizationOptionSound;
110
       types += UNAuthorizationOptionSound;
87
     }
111
     }
88
 
112
 
89
-    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
90
-
91
-    [center requestAuthorizationWithOptions:types
92
-                          completionHandler:^(BOOL granted, NSError * _Nullable error) {
113
+    [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:types
114
+                                                                        completionHandler:^(BOOL granted, NSError * _Nullable error) {
93
       if (error != nil) {
115
       if (error != nil) {
94
         return reject(error);
116
         return reject(error);
95
       }
117
       }
118
+
96
       if (granted) {
119
       if (granted) {
97
         dispatch_async(dispatch_get_main_queue(), ^{
120
         dispatch_async(dispatch_get_main_queue(), ^{
98
           [[UIApplication sharedApplication] registerForRemoteNotifications];
121
           [[UIApplication sharedApplication] registerForRemoteNotifications];
99
         });
122
         });
100
       }
123
       }
101
 
124
 
102
-      [self checkWithResolver:resolve rejecter:reject];
125
+      [RNPermissions flagAsRequested:[[self class] handlerUniqueId]];
126
+      [self checkWithResolver:self->_resolve rejecter:self->_reject];
103
     }];
127
     }];
104
   } else {
128
   } else {
105
-    UIUserNotificationType types = UIUserNotificationTypeNone;
106
-
107
-    if (alert) types += UIUserNotificationTypeAlert;
108
-    if (badge) types += UIUserNotificationTypeBadge;
109
-    if (sound) types += UIUserNotificationTypeSound;
129
+    if ([RNPermissions isFlaggedAsRequested:[[self class] handlerUniqueId]]) {
130
+      [self checkWithResolver:_resolve rejecter:_reject];
131
+    } else {
132
+      UIUserNotificationType types = UIUserNotificationTypeNone;
110
 
133
 
111
-    if (!alert && !badge && !sound) {
112
-      types += UIUserNotificationTypeAlert;
113
-      types += UIUserNotificationTypeBadge;
114
-      types += UIUserNotificationTypeSound;
115
-    }
134
+      if (alert) types += UIUserNotificationTypeAlert;
135
+      if (badge) types += UIUserNotificationTypeBadge;
136
+      if (sound) types += UIUserNotificationTypeSound;
116
 
137
 
117
-    _resolve = resolve;
118
-    _reject = reject;
138
+      if (!alert && !badge && !sound) {
139
+        types += UIUserNotificationTypeAlert;
140
+        types += UIUserNotificationTypeBadge;
141
+        types += UIUserNotificationTypeSound;
142
+      }
119
 
143
 
120
-    [[NSNotificationCenter defaultCenter] addObserver:self
121
-                                            selector:@selector(onApplicationDidBecomeActive)
122
-                                                name:UIApplicationDidBecomeActiveNotification
123
-                                              object:nil];
144
+      [[NSNotificationCenter defaultCenter] addObserver:self
145
+                                               selector:@selector(onApplicationDidBecomeActive)
146
+                                                   name:UIApplicationDidBecomeActiveNotification
147
+                                                 object:nil];
124
 
148
 
125
-    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
126
-    [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
127
-    [[UIApplication sharedApplication] registerForRemoteNotifications];
149
+      UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
150
+      [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
151
+      [[UIApplication sharedApplication] registerForRemoteNotifications];
152
+    }
128
   }
153
   }
129
 }
154
 }
130
 
155
 
133
                                                   name:UIApplicationDidBecomeActiveNotification
158
                                                   name:UIApplicationDidBecomeActiveNotification
134
                                                 object:nil];
159
                                                 object:nil];
135
 
160
 
161
+  [RNPermissions flagAsRequested:[[self class] handlerUniqueId]];
136
   [self checkWithResolver:_resolve rejecter:_reject];
162
   [self checkWithResolver:_resolve rejecter:_reject];
137
 }
163
 }
138
 
164
 
139
-- (void)getSettingsWithResolver:(void (^ _Nonnull)(NSDictionary * _Nonnull settings))resolve {
140
-  if (@available(iOS 10.0, *)) {
141
-    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
142
-
143
-    [center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
144
-      NSMutableDictionary *result = [NSMutableDictionary new];
145
-
146
-      bool alert = settings.alertSetting == UNNotificationSettingEnabled;
147
-      bool badge = settings.badgeSetting == UNNotificationSettingEnabled;
148
-      bool sound = settings.soundSetting == UNNotificationSettingEnabled;
149
-      bool lockScreen = settings.lockScreenSetting == UNNotificationSettingEnabled;
150
-      bool carPlay = settings.carPlaySetting == UNNotificationSettingEnabled;
151
-
152
-      if (settings.alertSetting != UNNotificationSettingNotSupported)
153
-        [result setValue:@(alert) forKey:@"alert"];
154
-      if (settings.badgeSetting != UNNotificationSettingNotSupported)
155
-        [result setValue:@(badge) forKey:@"badge"];
156
-      if (settings.soundSetting != UNNotificationSettingNotSupported)
157
-        [result setValue:@(sound) forKey:@"sound"];
158
-      if (settings.lockScreenSetting != UNNotificationSettingNotSupported)
159
-        [result setValue:@(lockScreen) forKey:@"lockScreen"];
160
-      if (settings.carPlaySetting != UNNotificationSettingNotSupported)
161
-        [result setValue:@(carPlay) forKey:@"carPlay"];
162
-
163
-      if (@available(iOS 12.0, *)) {
164
-        bool criticalAlert = settings.criticalAlertSetting == UNNotificationSettingEnabled;
165
-
166
-        if (settings.criticalAlertSetting != UNNotificationSettingNotSupported)
167
-          [result setValue:@(criticalAlert) forKey:@"criticalAlert"];
168
-      }
169
-
170
-      resolve(result);
171
-    }];
172
-  } else {
173
-    UIUserNotificationType types = [[[UIApplication sharedApplication] currentUserNotificationSettings] types];
174
-
175
-    resolve(@{
176
-      @"alert": @((bool)(types & UIUserNotificationTypeAlert)),
177
-      @"badge": @((bool)(types & UIUserNotificationTypeBadge)),
178
-      @"sound": @((bool)(types & UIUserNotificationTypeSound)),
179
-    });
180
-  }
181
-}
182
-
183
 @end
165
 @end

+ 3
- 11
ios/RNPermissions.h Ver arquivo

77
 
77
 
78
 @end
78
 @end
79
 
79
 
80
-@protocol RNPermissionWithRequestOptions <NSObject>
81
-
82
-@required
83
-
84
-- (void)requestWithResolver:(void (^ _Nonnull)(RNPermissionStatus status))resolve
85
-                   rejecter:(void (^ _Nonnull)(NSError * _Nonnull error))reject
86
-                    options:(NSArray<NSString *> * _Nonnull)options;
87
-
88
-@end
89
-
90
 @interface RNPermissions : NSObject <RCTBridgeModule>
80
 @interface RNPermissions : NSObject <RCTBridgeModule>
91
 
81
 
92
-+ (bool)hasAlreadyBeenRequested:(id<RNPermissionHandler> _Nonnull)handler;
82
++ (bool)isFlaggedAsRequested:(NSString * _Nonnull)handlerId;
83
+
84
++ (void)flagAsRequested:(NSString * _Nonnull)handlerId;
93
 
85
 
94
 + (bool)isBackgroundModeEnabled:(NSString * _Nonnull)mode;
86
 + (bool)isBackgroundModeEnabled:(NSString * _Nonnull)mode;
95
 
87
 

+ 28
- 22
ios/RNPermissions.m Ver arquivo

225
   }
225
   }
226
 }
226
 }
227
 
227
 
228
-+ (void)setRequested:(id<RNPermissionHandler> _Nonnull)handler {
228
++ (bool)isFlaggedAsRequested:(NSString * _Nonnull)handlerId {
229
+  NSArray<NSString *> *requested = [[NSUserDefaults standardUserDefaults] arrayForKey:SETTING_KEY];
230
+  return requested == nil ? false : [requested containsObject:handlerId];
231
+}
232
+
233
++ (void)flagAsRequested:(NSString * _Nonnull)handlerId {
229
   NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
234
   NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
230
-  NSString *handlerUniqueId = [[handler class] handlerUniqueId];
231
   NSMutableArray *requested = [[userDefaults arrayForKey:SETTING_KEY] mutableCopy];
235
   NSMutableArray *requested = [[userDefaults arrayForKey:SETTING_KEY] mutableCopy];
232
 
236
 
233
   if (requested == nil) {
237
   if (requested == nil) {
234
     requested = [NSMutableArray new];
238
     requested = [NSMutableArray new];
235
   }
239
   }
236
 
240
 
237
-  if (![requested containsObject:handlerUniqueId]) {
238
-    [requested addObject:handlerUniqueId];
241
+  if (![requested containsObject:handlerId]) {
242
+    [requested addObject:handlerId];
239
     [userDefaults setObject:requested forKey:SETTING_KEY];
243
     [userDefaults setObject:requested forKey:SETTING_KEY];
240
     [userDefaults synchronize];
244
     [userDefaults synchronize];
241
   }
245
   }
242
 }
246
 }
243
 
247
 
244
-+ (bool)hasAlreadyBeenRequested:(id<RNPermissionHandler> _Nonnull)handler {
245
-  NSArray<NSString *> *requested = [[NSUserDefaults standardUserDefaults] arrayForKey:SETTING_KEY];
246
-  return requested == nil ? false : [requested containsObject:[[handler class] handlerUniqueId]];
247
-}
248
-
249
 + (bool)isBackgroundModeEnabled:(NSString * _Nonnull)mode {
248
 + (bool)isBackgroundModeEnabled:(NSString * _Nonnull)mode {
250
   NSArray *modes = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIBackgroundModes"];
249
   NSArray *modes = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIBackgroundModes"];
251
   return [modes isKindOfClass:[NSArray class]] && [modes containsObject:mode];
250
   return [modes isKindOfClass:[NSArray class]] && [modes containsObject:mode];
278
   id<RNPermissionHandler> handler = [self handlerForPermission:permission];
277
   id<RNPermissionHandler> handler = [self handlerForPermission:permission];
279
 
278
 
280
   [handler checkWithResolver:^(RNPermissionStatus status) {
279
   [handler checkWithResolver:^(RNPermissionStatus status) {
281
-    resolve([self stringForStatus:status]);
280
+    NSString *strStatus = [self stringForStatus:status];
281
+    NSLog(@"[react-native-permissions] %@ permission checked: %@", [[handler class] handlerUniqueId], strStatus);
282
+    resolve(strStatus);
282
   } rejecter:^(NSError *error) {
283
   } rejecter:^(NSError *error) {
284
+    NSLog(@"[react-native-permissions] %@ permission failed: %@", [[handler class] handlerUniqueId], error.localizedDescription);
283
     reject([NSString stringWithFormat:@"%ld", (long)error.code], error.localizedDescription, error);
285
     reject([NSString stringWithFormat:@"%ld", (long)error.code], error.localizedDescription, error);
284
   }];
286
   }];
285
 }
287
 }
291
   id<RNPermissionHandler> handler = [self handlerForPermission:permission];
293
   id<RNPermissionHandler> handler = [self handlerForPermission:permission];
292
 
294
 
293
   [handler requestWithResolver:^(RNPermissionStatus status) {
295
   [handler requestWithResolver:^(RNPermissionStatus status) {
294
-    [RNPermissions setRequested:handler];
295
-    resolve([self stringForStatus:status]);
296
+    NSString *strStatus = [self stringForStatus:status];
297
+    NSLog(@"[react-native-permissions] %@ permission checked: %@", [[handler class] handlerUniqueId], strStatus);
298
+    resolve(strStatus);
296
   } rejecter:^(NSError *error) {
299
   } rejecter:^(NSError *error) {
300
+    NSLog(@"[react-native-permissions] %@ permission failed: %@", [[handler class] handlerUniqueId], error.localizedDescription);
297
     reject([NSString stringWithFormat:@"%ld", (long)error.code], error.localizedDescription, error);
301
     reject([NSString stringWithFormat:@"%ld", (long)error.code], error.localizedDescription, error);
298
   }];
302
   }];
299
 }
303
 }
304
 #if __has_include("RNPermissionHandlerNotifications.h")
308
 #if __has_include("RNPermissionHandlerNotifications.h")
305
   RNPermissionHandlerNotifications *handler = [RNPermissionHandlerNotifications new];
309
   RNPermissionHandlerNotifications *handler = [RNPermissionHandlerNotifications new];
306
 
310
 
307
-  [handler checkWithResolver:^(RNPermissionStatus status) {
308
-    [handler getSettingsWithResolver:^(NSDictionary * _Nonnull settings) {
309
-      resolve(@{ @"status": [self stringForStatus:status], @"settings": settings });
310
-    }];
311
+  [handler checkWithResolver:^(RNPermissionStatus status, NSDictionary * _Nonnull settings) {
312
+    NSString *strStatus = [self stringForStatus:status];
313
+    NSLog(@"[react-native-permissions] %@ permission checked: %@", [[handler class] handlerUniqueId], strStatus);
314
+    resolve(@{ @"status": strStatus, @"settings": settings });
311
   } rejecter:^(NSError * _Nonnull error) {
315
   } rejecter:^(NSError * _Nonnull error) {
316
+    NSLog(@"[react-native-permissions] %@ permission failed: %@", [[handler class] handlerUniqueId], error.localizedDescription);
312
     reject([NSString stringWithFormat:@"%ld", (long)error.code], error.localizedDescription, error);
317
     reject([NSString stringWithFormat:@"%ld", (long)error.code], error.localizedDescription, error);
313
   }];
318
   }];
314
 #else
319
 #else
315
-  reject(@"notification_missing", @"Notification permission handler is missing", nil);
320
+  reject(@"notifications_pod_missing", @"Notifications permission pod is missing", nil);
316
 #endif
321
 #endif
317
 }
322
 }
318
 
323
 
323
 #if __has_include("RNPermissionHandlerNotifications.h")
328
 #if __has_include("RNPermissionHandlerNotifications.h")
324
   RNPermissionHandlerNotifications *handler = [RNPermissionHandlerNotifications new];
329
   RNPermissionHandlerNotifications *handler = [RNPermissionHandlerNotifications new];
325
 
330
 
326
-  [handler requestWithResolver:^(RNPermissionStatus status) {
327
-    [handler getSettingsWithResolver:^(NSDictionary * _Nonnull settings) {
328
-      resolve(@{ @"status": [self stringForStatus:status], @"settings": settings });
329
-    }];
331
+  [handler requestWithResolver:^(RNPermissionStatus status, NSDictionary * _Nonnull settings) {
332
+    NSString *strStatus = [self stringForStatus:status];
333
+    NSLog(@"[react-native-permissions] %@ permission checked: %@", [[handler class] handlerUniqueId], strStatus);
334
+    resolve(@{ @"status": strStatus, @"settings": settings });
330
   } rejecter:^(NSError * _Nonnull error) {
335
   } rejecter:^(NSError * _Nonnull error) {
336
+    NSLog(@"[react-native-permissions] %@ permission failed: %@", [[handler class] handlerUniqueId], error.localizedDescription);
331
     reject([NSString stringWithFormat:@"%ld", (long)error.code], error.localizedDescription, error);
337
     reject([NSString stringWithFormat:@"%ld", (long)error.code], error.localizedDescription, error);
332
   } options:options];
338
   } options:options];
333
 #else
339
 #else
334
-  reject(@"notification_missing", @"Notification permission handler is missing", nil);
340
+  reject(@"notifications_pod_missing", @"Notifications permission pod is missing", nil);
335
 #endif
341
 #endif
336
 }
342
 }
337
 
343