Firebase-ios-sdk: Firebase register token for FCM doesn't work after app transfer

Created on 27 Nov 2018  路  18Comments  路  Source: firebase/firebase-ios-sdk

[REQUIRED] Step 2: Describe your environment

  • Xcode version: 10.1
  • Firebase SDK version: 5.13.0
  • Firebase Component: Auth, Core, Database, Messaging, Storage
  • Swift Version: 4.2

[REQUIRED] Step 3: Describe the problem

Recently transferred my app to a new Apple ID. I created/upload all of the new certificates for push notifications to firebase console (APN Auth Key). Also, set up other IOS certificates ("IOS distribution", "Apple Push Services") and made sure appID was added with push notifications enabled. My problem is the old firebase register tokens already stored in my database don't seem to work anymore. Once I reinstall the app or get the token to refresh the push notifications work. But again if I were to use the old tokens that were created before the app transfer the push notification fails to send.
What would be the best way to create new push notification tokens for users that have the old token? After reading the firebase docs the only way to create a new token would be if the user does one of the three things below.

  • The app is restored on a new device
  • The user uninstalls/reinstall
  • The user clears app data.

Yet all of those things seem like something the user would have to do themselves.

After doing a bit more research I found this similar issue Change/update Firebase notification token or instance id forcefully via code?. There suggestion was to

1) Delete old Token

let instance = InstanceID.instanceID()
instance.deleteID { (error) in
    print(error.debugDescription)
}

2) Request for new token

if let token = InstanceID.instanceID().token() {
    print("Token : \(token)");
} else {
    print(鈥淓rror: unable to fetch token");
}
Messaging.messaging().shouldEstablishDirectChannel = true

Which worked, when I call deleteID on the instanceID the MessagingDelegate's "didReceiveRegistrationToken" is called with the new fcmToken. I then update Database with new token. But this new fcmToken does not work, when I try to send a push notification through the firebase cloud messaging console nothing is received on the phones end. Yet if I were to delete the app and reinstall it, the first fcmToken works. The App receives all push notifications until I try to force update the FCMToken.

Again my goal is to update users with old FCMTokens to new ones so they can receive push notifications without having to reinstall the app or get the old FCM token to work.

messaging

Most helpful comment

Hi @stshelton,

Have you anyhow resolved this issue?

I have exactly the same problem. Apps being subscribed for notifications before app transfer don't get notifications after I updated certificate on firebase console.

Thanks for any hint on it!

All 18 comments

When you switch app certificates, normally a new APNS token is generated and FCM should automatically do a token fetch during app starts which returns a new token associated with your new apns token. And if you force calling deleteID, it will definitely refresh a new FCM token with the new APNS token. (you don't need to call getToken again as long as your have FIRMessaging.autoInitEnabled on)

So you shouldn't need to do anything as long as your APNS token has changed (you might want to double check that). And yes your old FCM token should NOT work, and you need to update it with your database.

For your development flow you can either
1: check if FCM token has changed from the one in your database, if yes, update the database.
2: if you already calling deleteID, then do that if user hasn't done so when switching to the new version of your app with your new apple ID. Make sure you only do that once.

If you tried either one and not working for you, Please send us the debug log or open a customer support ticket, we will look more into it.

Ok let me try the few things you suggested. Also technically I haven't sent out an update on new Apple ID just transferred apps. Do you think if I sent out an update that may help tokens automatically refresh?

Do you mean that you haven't switch your app certificate on your app yet? What about the console? have you updated the new certificate to the FCM settings?

No, I did switch app certificates and I updated FCM settings with new APN certificate. But at the time I did not actually submit a new build to the new Apple ID. When transferring apps between Apple IDs I didn't have to submit a new build, I just transferred the current build that was on the old Apple ID to new Apple ID. But this past weekend I sent out an update with new Apple ID, and the users that had old FCM token in the database did receive an updated token. Yet the updated token still doesn't seem to work, the only way I got there token to refresh and work is if the user deletes and redownloads the app.

@stshelton, can you open a support ticket and reference this issue? When filling out the form, please share your FCM tokens that failing to receive pushes and we'll be able to look at what's happening to them on the backend.

Closing since this is resolved (I think)--please re-open if I'm wrong

Hi @stshelton,

Have you anyhow resolved this issue?

I have exactly the same problem. Apps being subscribed for notifications before app transfer don't get notifications after I updated certificate on firebase console.

Thanks for any hint on it!

@chliangGoogle
Im also facing same issue. Apps will not receive push notification after the app transfer even after i have updated the apns token key in firebase console settings, so to make it work i have to uninstall and reinstall app again then apps started receiving push notification.

We are facing the same problem.

We have transferred the IOS app to a new account and now we can only push to our IOS users after the remove and install the app again.

Please, any advice on what to do will be greatly appreciated! Having to communicate to ALL IOS users that they have to reinstall their app is devastating!

Thanks in advance.

@JakobMaaloe Can you check if your APNS token and FCM token have changed in the same app after you make the transition?
Can you share a test APNS token and FCM token with us so we can bring the issue to our team. If you are not comfortable sharing the token, can you open a support ticket and reference this issue?

Thanks for the ultra quick response ChliangGoogle!

We have created a new APNs Auth Key as part of the set up, since the old one belongs to the old account.
This is a test push token id of one of our test users that currently haven't uninstalled his app yet:
f0rtVkM3cRw:APA91bGaT-hhmffRFjt0VAZNjb1aYjuJWxTkq82QyC43DxXdbYvHUUML8-uEoMB-moUtb8DjMVZtZxle0rMCkjgLVMJiRA5ttqKMc2nh7z96TfdBj-dHpvov86hqYs9bRP-Kg7JMxKaU

I'm unsure what an APNs Token is or where to retrieve it...

Thanks a lot for your support!

We've just tried the following:

  1. Reinstall the app on a device
  2. Push message from our server to the FCM token -> The user receives the message
  3. Change APN auth key to an old one
  4. Change APN auth key back to the new one
  5. Delete the FCM token on our server
  6. App requests new FCM token on startup and receives the same FCM token as before it was deleted
  7. Push message from our server to the FCM token -> The user doesn't receive the message

One solution could be if we could force all users FCM token to refresh... Any way that's possible?

I can send you the APNS token from Apple console in a support ticket if you still need it.

Thanks for the detailed info. You can use this Apple API to get the APNS token.

Can you also do the same steps and let us know if your APNS token is updated along with the non-changed FCM token?

That requires that we update the app which is something we cannot do at this point with the production app.

Support case created with the APNs (from apple console - I hope this can be used).

Moving to new thread....

Same issue!! Any solution?

can you share the information that if you APNS token and FCM token has changed during this transition? And let us know your old and new tokens.

FirebaseCore 6.1.0
FirebaseDatabase 6.0.0
FirebaseFirestore 1.4.2
FirebaseInstanceID 4.2.2
FirebaseMessaging 4.1.1
FirebaseStorage 3.4.0
GTMSessionFetcher 1.2.2

I am having same Issue with updated firebase versions.

Was this page helpful?
0 / 5 - 0 ratings