class NotifHandler {
onNotification(notification) {
console.log('onNotifHandler:', notification);
if (typeof this._onNotification === 'function') {
this._onNotification(notification);
}
}
onRegister(token) {
// console.log('NotifHandler:', token);
if (typeof this._onRegister === 'function') {
this._onRegister(token);
}
}
onRemoteFetch(notificationData) {
console.log('onRemoteFetchNotifHandler:', notificationData);
}
attachRegister(handler) {
this._onRegister = handler;
}
attachNotification(handler) {
this._onNotification = handler;
}
}
const handler = new NotifHandler();
PushNotification.configure({
// (optional) Called when Token is generated (iOS and Android)
onRegister: handler.onRegister.bind(handler),
// (required) Called when a remote or local notification is opened or received
onNotification: handler.onNotification.bind(handler),
// IOS ONLY (optional): default: all - Permissions to register.
permissions: {
alert: true,
badge: true,
sound: true,
},
// Should the initial notification be popped automatically
// default: true
popInitialNotification: true,
/**
* (optional) default: true
* - Specified if permissions (ios) and token (android and ios) will requested or not,
* - if not, you must call PushNotificationsHandler.requestPermissions() later
*/
requestPermissions: true,
});
But after 10 seconds notification is work well, but onNotification seems not working when notification is showing.
How to get callback notification when showing, not by tapping?
I try to implementation like this:
But after 10 seconds notification is work well, but
onNotification
seems not working when notification is showing. How to get callback notification when showing, not by tapping?