diff --git a/README.md b/README.md index 1975a2dc..44359d4d 100644 --- a/README.md +++ b/README.md @@ -184,6 +184,9 @@ export const App = () => { } else { // Do something else with push notification } + // Use the appropriate result based on what you needed to do for this notification + const result = PushNotificationIOS.FetchResult.NoData; + notification.finish(result); }; }; ``` @@ -239,6 +242,9 @@ export const App = () => { const userText = notification.getUserText(); // Perform action based on textinput action } + // Use the appropriate result based on what you needed to do for this notification + const result = PushNotificationIOS.FetchResult.NoData; + notification.finish(result); }; }; ``` diff --git a/example/App.js b/example/App.js index 371c4c9a..acace09d 100644 --- a/example/App.js +++ b/example/App.js @@ -290,6 +290,7 @@ export const App = (): React.Node => { }, ]); } + notification.finish('UIBackgroundFetchResultNoData') }; const onLocalNotification = (notification) => { diff --git a/ios/RNCPushNotificationIOS.m b/ios/RNCPushNotificationIOS.m index ca683648..bc6bb3d3 100644 --- a/ios/RNCPushNotificationIOS.m +++ b/ios/RNCPushNotificationIOS.m @@ -169,7 +169,13 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification RCT_EXPORT_METHOD(onFinishRemoteNotification:(NSString *)notificationId fetchResult:(UIBackgroundFetchResult)result) { - [self.remoteNotificationCallbacks removeObjectForKey:notificationId]; + if (self.remoteNotificationCallbacks) { + RNCRemoteNotificationCallback completionHandler = [self.remoteNotificationCallbacks objectForKey:notificationId]; + if (completionHandler) { + completionHandler(result); + } + [self.remoteNotificationCallbacks removeObjectForKey:notificationId]; + } } /** diff --git a/package.json b/package.json index 37a9570c..9bd9a5be 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@react-native-community/push-notification-ios", - "version": "1.10.1", + "version": "1.11.0", "description": "React Native Push Notification API for iOS", "main": "js/index.js", "types": "index.d.ts",