Reputation: 13
I need know the function to detect the notifications. I can send and receive notifications, but i need a function to detect when receive the notification.
Upvotes: 1
Views: 550
Reputation: 3948
The notificationOpenedCallback
will fire when a notification is either opened or if one is received while the app is in focus. Example below.
var notificationOpenedCallback = function(jsonData) {
console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(jsonData));
};
window.plugins.OneSignal.init("b2f7f966-d8cc-11e4-bed1-df8f05be55ba",
{googleProjectNumber: "703322744261"},
notificationOpenedCallback);
There isn't an event for when a notification is receive in the background through Corodva. You will need to use native code for this by setting up a NotificationExtenderService
in Java by following the OneSignal Background Data and Notification Overriding documentation for Android. For iOS set content_available
to true and setup a
- application:didReceiveRemoteNotification:fetchCompletionHandler: selector.
Upvotes: 1