FirebaseInstanceIdService is deprecated

后端 未结 10 2321

Hope all of you aware of this class, used to get notification token whenever firebase notification token got refreshed we get the refreshed token from this class, From follo

10条回答
  •  爱一瞬间的悲伤
    2020-11-22 10:38

    And this:

    FirebaseInstanceId.getInstance().getInstanceId().getResult().getToken()
    

    suppose to be solution of deprecated:

    FirebaseInstanceId.getInstance().getToken()
    

    EDIT

    FirebaseInstanceId.getInstance().getInstanceId().getResult().getToken() can produce exception if the task is not yet completed, so the method witch Nilesh Rathod described (with .addOnSuccessListener) is correct way to do it.

    Kotlin:

    FirebaseInstanceId.getInstance().instanceId.addOnSuccessListener(this) { instanceIdResult ->
            val newToken = instanceIdResult.token
            Log.e("newToken", newToken)
        }
    

提交回复
热议问题