Protect against multiple calls to start/stop handling native methods

This commit is contained in:
Ryan Grey 2018-08-06 15:19:05 +01:00
parent b53695ad52
commit 0291605934
1 changed files with 10 additions and 0 deletions

View File

@ -99,12 +99,22 @@ RCT_EXPORT_MODULE();
} }
RCT_EXPORT_METHOD(startHandlingNotificationDisplayed) { RCT_EXPORT_METHOD(startHandlingNotificationDisplayed) {
if(isUserHandlingOnNotificationDisplayed == YES) {
return;
}
isUserHandlingOnNotificationDisplayed = YES; isUserHandlingOnNotificationDisplayed = YES;
completionHandlers = [[NSMutableDictionary alloc] init]; completionHandlers = [[NSMutableDictionary alloc] init];
} }
RCT_EXPORT_METHOD(stopHandlingNotificationDisplayed) { RCT_EXPORT_METHOD(stopHandlingNotificationDisplayed) {
if(isUserHandlingOnNotificationDisplayed == NO) {
return;
}
isUserHandlingOnNotificationDisplayed = NO; isUserHandlingOnNotificationDisplayed = NO;
NSArray *allHandlers = completionHandlers.allValues; NSArray *allHandlers = completionHandlers.allValues;
for (void (^ completionHandler)(UIBackgroundFetchResult) in allHandlers) { for (void (^ completionHandler)(UIBackgroundFetchResult) in allHandlers) {
completionHandler(UIBackgroundFetchResultNoData); completionHandler(UIBackgroundFetchResultNoData);