Firebase register token for FCM doesn't work after app transfer











up vote
0
down vote

favorite












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 ones to work.










share|improve this question




























    up vote
    0
    down vote

    favorite












    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 ones to work.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      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 ones to work.










      share|improve this question















      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 ones to work.







      ios swift firebase firebase-cloud-messaging






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 at 1:02

























      asked Nov 20 at 2:33









      Spencer Shelton

      6816




      6816





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53385386%2ffirebase-register-token-for-fcm-doesnt-work-after-app-transfer%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53385386%2ffirebase-register-token-for-fcm-doesnt-work-after-app-transfer%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          TypeError: fit_transform() missing 1 required positional argument: 'X'