How to handle FirebaseInstanceId.getInstance().getToken() = null

前端 未结 7 2121
情书的邮戳
情书的邮戳 2020-12-05 15:43

I have just migrated to FCM. I have added my class that extends from FirebaseInstanceIdService to receive a refreshedToken as and when appropriate.

My question is sp

相关标签:
7条回答
  • 2020-12-05 16:15

    depending on your application logic you can write the code to handle the "new" token directly in the FirebaseInstanceIdService.onTokenRefresh() method, or you can use a LocalBroadcast to send this information to your activity if you need to change the UI when this event happens.

    Note that when onTokenRefresh() is called your activity could be closed.

    A possible implementation could a mix of the two options:

    1. add some logic in onTokenRefresh() to send the token to your server
    2. use a LocalBroadcastReceiver to inform your activity, if you have a piece of UI that need to change when the token is available.
    0 讨论(0)
提交回复
热议问题