Open alexandergx opened 1 year ago
I have the same issue
PushNotificationIOS.requestPermissions().then(data => { PushNotificationIOS.addEventListener('register', token => { alert(token); }); });
In this library, I have found that you have to call PushNotificationIOS.addEventListener('register'
before PushNotificationIOS.requestPermissions
so register is triggered after the user presses allow. Also if you want to get the device token on every reload, you could call a silent local notification to trigger the register event. Like so;
PushNotificationIOS.addNotificationRequest({
id: 'default',
title: '',
body: '',
isSilent: true,
});
The "register" and "registerError" events don't seem to fire on React Native version 0.70.6. I just tried a fresh project init, and still no success.
package.json:
"react": "18.1.0", "react-native": "0.70.6"
AppDelegate.h and AppDelegate.mm have been configured properly. Xcode Background Mode > Remote Notifications and Push Notifications have been set properly. App builds and runs fine. But the two listener events do not ever fire.
Is this known? Are there any solutions?