Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completion handler is not called #311

Merged
merged 7 commits into from
Oct 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
};
```
Expand Down Expand Up @@ -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);
};
};
```
Expand Down
1 change: 1 addition & 0 deletions example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ export const App = (): React.Node => {
},
]);
}
notification.finish('UIBackgroundFetchResultNoData')
};

const onLocalNotification = (notification) => {
Expand Down
8 changes: 7 additions & 1 deletion ios/RNCPushNotificationIOS.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down