react-native-push-notification / ios

React Native Push Notification API for iOS.
MIT License
741 stars 285 forks source link

IOS - onRegister() returns different token than messaging().getToken() #218

Open lucaspdude opened 3 years ago

lucaspdude commented 3 years ago

I'm facing a problem with my app in IOS.

My onRegister gets a different token then on my messaging().getToken();

onRegister():

onRegister(token) {
    console.log('NotificationHandler:', token);

    storeData(token.token, 'notifFCMToken');

    if (typeof this._onRegister === 'function') {
      this._onRegister(token);
    }
  }

onRegister() returns:

{
os: "ios"
token: "5642e18e4b469c944b7431b26d8a5b172cf66d1fb155a0bbd2fb2d19837d9bd0"
}

messaging().getToken() : const FCMToken = await messaging().getToken(); messaging().getToken() returns: dJ7Q9m7PF0cKp4mTr21HZO:APA91bFQv5w9jOlj_qNiHanoBtFa0M7wYdNeMWkxR_I-KW-EoPszZWFfhmysqv91cRLO7eO9A4BAeniJqDsAqcDYDVWMl42n11igVWi7l05KapRU_0RdOI8W-ltRUde6xoR6qw5WC8Xj

On ANDROID it returns the same token on both methods.

Environment info

    "react": "16.13.1",
    "react-native": "0.63.1",

Library version: @react-native-community/push-notification-ios": "^1.5.0"

rarenatoe commented 3 years ago

I am facing the same issue

axeljeremy7 commented 3 years ago

don't use getToken() thats for fcm, you need to use APNsToken() i think, that one will be the same as the onregister