How to convert a FCM token to APNS token?
Asked Answered
F

2

13

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?

Filet answered 22/8, 2018 at 18:4 Comment(3)
@Moonwalkr Am I still supposed to explain my downvotes or not?Curr
@DalijaPrasnikar As that answer says: "What is helpful is constructive feedback: Please consider adding a comment if you think this post can be improved." Does your (if it was you) lack of comment mean that you DON'T think the post can be improved? My comment stands: it is POLITE to say why you downvoted. If you want SO to be a better place, then you should leave a comment explaining what the OP should have done with his Q instead, or why you think the Q should not have been asked.Colettacolette
@Moonwalkr You didn't ask the downvoter to provide helpful and constructive feedback, you said that downvoting without leaving the comment is not POLITE, thus saying downvoter is not polite or implying downvoter was rude. Also your comment implies that people should comment on their votes while there is actually no such requirement. On the contrary, people should not comment on their votes, but leave feedback IF they think post can be improved and even then they are free to decide whether they wish to comment or not.Curr
S
1

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,
          );
        });
    });
Seringa answered 22/9, 2019 at 15:54 Comment(0)
G
-1

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.

Golanka answered 10/3, 2020 at 10:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.