|
@@ -225,6 +225,18 @@ RCT_EXPORT_MODULE();
|
225
|
225
|
}
|
226
|
226
|
}
|
227
|
227
|
|
|
228
|
+- (NSString *)insertHandler:(id<RNPermissionHandler>)handler {
|
|
229
|
+ if( self.handlers == nil){
|
|
230
|
+ self.handlers = [NSMutableDictionary new];
|
|
231
|
+ }
|
|
232
|
+
|
|
233
|
+ NSString *randomId = [[NSUUID UUID] UUIDString];
|
|
234
|
+
|
|
235
|
+ [self.handlers setObject:handler forKey:randomId];
|
|
236
|
+
|
|
237
|
+ return randomId;
|
|
238
|
+}
|
|
239
|
+
|
228
|
240
|
+ (bool)isFlaggedAsRequested:(NSString * _Nonnull)handlerId {
|
229
|
241
|
NSArray<NSString *> *requested = [[NSUserDefaults standardUserDefaults] arrayForKey:SETTING_KEY];
|
230
|
242
|
return requested == nil ? false : [requested containsObject:handlerId];
|
|
@@ -271,13 +283,19 @@ RCT_REMAP_METHOD(check,
|
271
|
283
|
rejecter:(RCTPromiseRejectBlock)reject) {
|
272
|
284
|
id<RNPermissionHandler> handler = [self handlerForPermission:permission];
|
273
|
285
|
|
|
286
|
+ NSString *randomId = [self insertHandler: handler];
|
|
287
|
+
|
274
|
288
|
[handler checkWithResolver:^(RNPermissionStatus status) {
|
275
|
289
|
NSString *strStatus = [self stringForStatus:status];
|
276
|
290
|
NSLog(@"[react-native-permissions] %@ permission checked: %@", [[handler class] handlerUniqueId], strStatus);
|
277
|
291
|
resolve(strStatus);
|
|
292
|
+
|
|
293
|
+ [self.handlers removeObjectForKey:randomId];
|
278
|
294
|
} rejecter:^(NSError *error) {
|
279
|
295
|
NSLog(@"[react-native-permissions] %@ permission failed: %@", [[handler class] handlerUniqueId], error.localizedDescription);
|
280
|
296
|
reject([NSString stringWithFormat:@"%ld", (long)error.code], error.localizedDescription, error);
|
|
297
|
+
|
|
298
|
+ [self.handlers removeObjectForKey:randomId];
|
281
|
299
|
}];
|
282
|
300
|
}
|
283
|
301
|
|
|
@@ -287,13 +305,19 @@ RCT_REMAP_METHOD(request,
|
287
|
305
|
rejecter:(RCTPromiseRejectBlock)reject) {
|
288
|
306
|
id<RNPermissionHandler> handler = [self handlerForPermission:permission];
|
289
|
307
|
|
|
308
|
+ NSString *randomId = [self insertHandler: handler];
|
|
309
|
+
|
290
|
310
|
[handler requestWithResolver:^(RNPermissionStatus status) {
|
291
|
311
|
NSString *strStatus = [self stringForStatus:status];
|
292
|
312
|
NSLog(@"[react-native-permissions] %@ permission checked: %@", [[handler class] handlerUniqueId], strStatus);
|
293
|
313
|
resolve(strStatus);
|
|
314
|
+
|
|
315
|
+ [self.handlers removeObjectForKey:randomId];
|
294
|
316
|
} rejecter:^(NSError *error) {
|
295
|
317
|
NSLog(@"[react-native-permissions] %@ permission failed: %@", [[handler class] handlerUniqueId], error.localizedDescription);
|
296
|
318
|
reject([NSString stringWithFormat:@"%ld", (long)error.code], error.localizedDescription, error);
|
|
319
|
+
|
|
320
|
+ [self.handlers removeObjectForKey:randomId];
|
297
|
321
|
}];
|
298
|
322
|
}
|
299
|
323
|
|