In the new Firebase, under Notification, they have mentioned that developer can send notification to a particular device. For that, in console it asks for an FCM token. What is it exactly and how can I get that token?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Here is simple steps add this gradle:
No extra permission are needed in manifest like GCM. No receiver is needed to manifest like GCM. With FCM,
com.google.android.gms.gcm.GcmReceiver
is added automatically.Migrate your listener service
A service extending
InstanceIDListenerService
is now required only if you want to access the FCM token.This is needed if you want to
Add Service in manifest
Change
MyInstanceIDListenerService
to extendFirebaseInstanceIdService
, and update code to listen for token updates and get the token whenever a new token is generated.For more information visit
FirebaseInstanceIdService is now deprecated. you should get the Token in the onNewToken method in the FirebaseMessagingService.
Check out the docs
What is it exactly?
An FCM Token, or much commonly known as a
registrationToken
like in google-cloud-messaging. As described in the GCM docs:How can I get that token?
Update: The token can still be retrieved by calling
getToken()
, however, as per FCM's latest version, theFirebaseInstanceIdService.onTokenRefresh()
has been replaced withFirebaseMessagingService.onNewToken()
-- which in my experience functions the same way asonTokenRefresh()
did.Old answer:
As per the FCM docs:
They deprecated getToken() method in the below release notes. Instead, we have to use getInstanceId.
https://firebase.google.com/docs/reference/android/com/google/firebase/iid/FirebaseInstanceId
To handle success and failure in the same listener, attach an OnCompleteListener:
Also, the FirebaseInstanceIdService Class is deprecated and they came up with onNewToken method in FireBaseMessagingService as replacement for onTokenRefresh,
you can refer to the release notes here, https://firebase.google.com/support/release-notes/android
I have an update about "Firebase Cloud Messaging token" which I could get an information.
I really wanted to know about that change so just sent a mail to Support team. The Firebase Cloud Messaging token will get back to Server key soon again. There will be nothing to change. We can see Server key again after soon.