Add a promise response to iOS messaging requestPermissions to return permission popup response (iOS 10+)
This commit is contained in:
parent
187f7cd7b9
commit
43df6b5564
|
@ -247,7 +247,7 @@ RCT_EXPORT_METHOD(getToken:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseR
|
|||
[_bridge.eventDispatcher sendDeviceEventWithName:@"FCMTokenRefreshed" body:[[FIRInstanceID instanceID] token]];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(requestPermissions)
|
||||
RCT_EXPORT_METHOD(requestPermissions:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
||||
{
|
||||
if (RCTRunningInAppExtension()) {
|
||||
return;
|
||||
|
@ -265,6 +265,9 @@ RCT_EXPORT_METHOD(requestPermissions)
|
|||
//iOS 7 or below
|
||||
[app registerForRemoteNotificationTypes:(NSUInteger)allNotificationTypes];
|
||||
}
|
||||
// Unfortunately on iOS 9 or below, there's no way to tell whether the user accepted or
|
||||
// rejected the permissions popup
|
||||
resolve(@{@"status":@"unknown"});
|
||||
} else {
|
||||
// iOS 10 or later
|
||||
#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
|
||||
|
@ -275,6 +278,7 @@ RCT_EXPORT_METHOD(requestPermissions)
|
|||
[[UNUserNotificationCenter currentNotificationCenter]
|
||||
requestAuthorizationWithOptions:authOptions
|
||||
completionHandler:^(BOOL granted, NSError * _Nullable error) {
|
||||
resolve(@{@"granted":@(granted)});
|
||||
}
|
||||
];
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue