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

[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(“Error: 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.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 18 (7 by maintainers)

Most upvoted comments

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!

@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.

@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.