onRegister fires correctly, but onNotification never catched
See original GitHub issueOn Android I have no problems, on iOS I am able to catch onRegister
event and get the token correctly, but when I test push notifications, the event onNotification
seems not working: it never fires.
My configure code is:
const configure = async () => {
console.log('push notification configured');
PushNotificationIOS.addEventListener('registrationError', (e) => { alert(JSON.stringify(e)) });
PushNotification.configure({
onRegister: function (token) {
//process token
alert('Token! ' + JSON.stringify(token));
console.log('[CATCHED] onRegister:', token);
db.setToken(token).catch(
console.log('[ERROR] device push token has not been saved on the database'),
);
},
onNotification: async function (notification) {
console.log('[CATCHED] onNotification: ' + JSON.stringify(notification));
let notifType = '';
//console.log('notification received: ' + JSON.stringify(notification));
if (Platform.OS === 'ios') {
notifType = getNotificationType(
JSON.parse(notification.data.data).type,
);
} else {
notifType = getNotificationType(
notification.type,
);
}
//console.log('notification type: >>>>>>>>>>>>>>>> ' + notifType);
//console.log('notification s: ------------------> ' + JSON.stringify(notification));
switch (notifType) {
{...}
}
// process the notification
// required on iOS only
if (Platform.OS === 'ios') {
notification.finish(PushNotificationIOS.FetchResult.NoData);
}
},
senderID: '-----',
permissions: {
alert: true,
badge: true,
sound: true,
},
popInitialNotification: true,
requestPermissions: true,
});
};
In iOS, the console log [CATCHED] onRegister:
fires correctly, but [CATCHED] onNotification:
is never fired.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:8
Top Results From Across the Web
react-native-push-notification onRegister fires correctly, but ...
On Android I have no problems, on iOS I am able to catch onRegister event and get the token correctly, but when I...
Read more >DocuPrint 5105 d User Guide - FUJIFILM Business Innovation
Never attempt any procedure on the machine that is not specifically described in this manual. ... catch fire and cause burn injuries or...
Read more >Health and Safety Policy - LCB Group
The Management of Health and Safety at Work Regulations (Regulation 5) requires the employer to have arrangements in place to cover health and...
Read more >Changelog - LTTng
[hc] * Fix: rotation may never complete in per-PID buffering mode * Fix: perform local data pending before checking data pending with relayd...
Read more >matrix-react-sdk | Yarn - Package Manager
This is a react-based SDK for inserting a Matrix chat/voip client into a web page. This package provides the React components needed to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
same for me, onNotification only listening when clicking on the notification, but not when receiving the notification / notification fires.
Issue resolved after using the latest version of this library and @react-native-community/push-notification-ios
Also added below code according to latest installation steps here