wix / react-native-notifications

React Native Notifications
MIT License
3.25k stars 764 forks source link

Unable to get Android device token through registerRemoteNotificationsRegistered #860

Closed kd4g closed 2 years ago

kd4g commented 2 years ago

I am using the following versions and followed all the steps outlined in https://wix.github.io/react-native-notifications/docs/installation-android

react-native-notifications": "^4.2.4" "react-native": "0.68.0",

registerRemoteNotificationsRegistered callback is not getting called after Notifications.registerRemoteNotifications(). So I am unable to get device token.

Here is the code snippet:

  Notifications.events().registerRemoteNotificationsRegistered(event => {.
      console.log(" Device Token Received" + event.deviceToken);
  }
  );
  Notifications.events().registerRemoteNotificationsRegistrationFailed((event) => {
      console.error(event);
  });

  Notifications.registerRemoteNotifications();

I ensured all changes are done to build.grade, gradle.settings as outlined in the document.

Any details about why callback is not called will be helpful.

Thanks!

ErkanGorgulu commented 2 years ago

I am having the same problem right now. Any solutions or workarounds?

abuzzell commented 2 years ago

+1

moonbe77 commented 2 years ago

Same on IOS device

robfrancis commented 2 years ago

Has anyone manage to resolve this issue yet? or have a workaround?

Anamcoollzz commented 2 years ago

Hmm, how to fix it :(

Bilal-Abdeen commented 2 years ago

I am having the same issue.

Notifications.events().registerRemoteNotificationsRegistered( (event) => { 
  // Code execution never reaches this point 
  console.log("registerRemoteNotificationsRegistered - deviceToken:", event.deviceToken, ); 
});

react-native: 0.68.2 react-native-notifications: 4.3.1

aljimsondev commented 2 years ago

Same issue here, any progress??

ls-andrew-borstein commented 2 years ago

In case it's helpful to anyone else, updating settings related to Google FCM fixed this issue for me. I was clued in by this comment and re-downloaded the google-services.json file. I also updated some of the gradle code based on what's in the docs. After updating all of that info, the token started magically appearing and the function body was now accessible.

My guess is the callback isn't run unless a valid token is present, which may not be returned if Google FCM isn't set up correctly.

"react-native": "0.67.4",
"react-native-notifications": "^4.2.4",
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] commented 2 years ago

The issue has been closed for inactivity.

nguyendinhdoan commented 1 year ago

I'm getting stuck on this issue too.

"react-native": "0.69.7",
"react-native-notifications": "4.3.5"