We consider migrating from Firebase Cloud Messaging to build our own push engine. We need to migrate the users converting FCM tokens to get the raw APNS token. How can that be done?
I can only find a procedure to convert APNS to FCM tokens. https://developers.google.com/instance-id/reference/server#create_registration_tokens_for_apns_tokens
Any way to decode the FCM tokens?
You can get the token from react-native-firebase with the following way.
firebase
.messaging()
.ios.registerForRemoteNotifications()
.then(() => {
console.log('REGISTER FOR REMOTE NOTIFICATIONS');
firebase
.messaging()
.ios.getAPNSToken()
.then(token => {
console.log(
'APNS TOKEN AFTER REGISTRATION FOR BACKGROUND',
token,
);
});
});
Doesn't directly answer the question but if you're using cordova-plugin-firebase
it's possible to get the APNS token from the plugin itself:
cordova.plugins.firebase.messaging.getToken('apns-string').then(apnsToken => console.log(apnsToken));
Passing the 'apns-string'
parameter means it returns the APNS token instead of the FCM token.