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

"register" and "registerError" events don't fire on React [email protected] [email protected] #400

Open
alexandergx opened this issue Apr 5, 2023 · 2 comments

Comments

@alexandergx
Copy link

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?

@atifgulzar
Copy link

atifgulzar commented Jun 2, 2023

I have the same issue

PushNotificationIOS.requestPermissions().then(data => { PushNotificationIOS.addEventListener('register', token => { alert(token); }); });

@ErkanGorgulu
Copy link

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,
      });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants