dimanche 8 novembre 2020

Unit test for getting the Firebase token on Android

I've just implemented the new way of getting the Firebase token on Android and I am trying to fix my unit test accordingly, unfortunately without any success. Does anyone could help?

The new way of getting the token based on the official doc looks like following:

FirebaseMessaging.getInstance().token.addOnCompleteListener(OnCompleteListener { task ->
    if (!task.isSuccessful) {
        Log.w(TAG, "Fetching FCM registration token failed", task.exception)
        return@OnCompleteListener
    }

    // Get new FCM registration token
    val token = task.result

    // Log and toast
    val msg = getString(R.string.msg_token_fmt, token)
    Log.d(TAG, msg)
    Toast.makeText(baseContext, msg, Toast.LENGTH_SHORT).show()
})

source: https://firebase.google.com/docs/cloud-messaging/android/client#kotlin+ktx

Any tips would be appreciated!

Aucun commentaire:

Enregistrer un commentaire