From 0291605934640004667ba44498efc66da7f985fe Mon Sep 17 00:00:00 2001 From: Ryan Grey Date: Mon, 6 Aug 2018 15:19:05 +0100 Subject: [PATCH] Protect against multiple calls to start/stop handling native methods --- ios/RNFirebase/notifications/RNFirebaseNotifications.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ios/RNFirebase/notifications/RNFirebaseNotifications.m b/ios/RNFirebase/notifications/RNFirebaseNotifications.m index 9de4e54f..3a2b6556 100644 --- a/ios/RNFirebase/notifications/RNFirebaseNotifications.m +++ b/ios/RNFirebase/notifications/RNFirebaseNotifications.m @@ -99,12 +99,22 @@ RCT_EXPORT_MODULE(); } RCT_EXPORT_METHOD(startHandlingNotificationDisplayed) { + if(isUserHandlingOnNotificationDisplayed == YES) { + return; + } + isUserHandlingOnNotificationDisplayed = YES; + completionHandlers = [[NSMutableDictionary alloc] init]; } RCT_EXPORT_METHOD(stopHandlingNotificationDisplayed) { + if(isUserHandlingOnNotificationDisplayed == NO) { + return; + } + isUserHandlingOnNotificationDisplayed = NO; + NSArray *allHandlers = completionHandlers.allValues; for (void (^ completionHandler)(UIBackgroundFetchResult) in allHandlers) { completionHandler(UIBackgroundFetchResultNoData);