Skip to content

Commit dd46810

Browse files
authored
Completion handler is not called (#311)
1 parent 3d0ca9a commit dd46810

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ export const App = () => {
184184
} else {
185185
// Do something else with push notification
186186
}
187+
// Use the appropriate result based on what you needed to do for this notification
188+
const result = PushNotificationIOS.FetchResult.NoData;
189+
notification.finish(result);
187190
};
188191
};
189192
```
@@ -239,6 +242,9 @@ export const App = () => {
239242
const userText = notification.getUserText();
240243
// Perform action based on textinput action
241244
}
245+
// Use the appropriate result based on what you needed to do for this notification
246+
const result = PushNotificationIOS.FetchResult.NoData;
247+
notification.finish(result);
242248
};
243249
};
244250
```

example/App.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ export const App = (): React.Node => {
290290
},
291291
]);
292292
}
293+
notification.finish('UIBackgroundFetchResultNoData')
293294
};
294295

295296
const onLocalNotification = (notification) => {

ios/RNCPushNotificationIOS.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,13 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification
169169

170170
RCT_EXPORT_METHOD(onFinishRemoteNotification:(NSString *)notificationId fetchResult:(UIBackgroundFetchResult)result)
171171
{
172-
[self.remoteNotificationCallbacks removeObjectForKey:notificationId];
172+
if (self.remoteNotificationCallbacks) {
173+
RNCRemoteNotificationCallback completionHandler = [self.remoteNotificationCallbacks objectForKey:notificationId];
174+
if (completionHandler) {
175+
completionHandler(result);
176+
}
177+
[self.remoteNotificationCallbacks removeObjectForKey:notificationId];
178+
}
173179
}
174180

175181
/**

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@react-native-community/push-notification-ios",
3-
"version": "1.10.1",
3+
"version": "1.11.0",
44
"description": "React Native Push Notification API for iOS",
55
"main": "js/index.js",
66
"types": "index.d.ts",

0 commit comments

Comments
 (0)