【问题标题】:Why is the service FirebaseInstanceIdService lost in the firebase new updates? [duplicate]为什么 Firebase 新更新中的服务 FirebaseInstanceIdService 会丢失? [复制]
【发布时间】:2019-12-13 23:15:22
【问题描述】:
问题是,我想在我的聊天应用中使用 Firebase 云消息传递。在我的 android studio 中实现 firebase 文档,我需要创建一个扩展 FirebaseInstanceIdService 的类。但是,似乎缺少此服务。
public class MyFirebaseInstanceIdService extends FirebaseInstanceIdService{
}
【问题讨论】:
标签:
java
android
firebase
firebase-cloud-messaging
【解决方案1】:
是的,FirebaseInstanceIdService 在新版本中已弃用。现在您可以在 MyFirebaseMessagingService 中获取更新后的令牌。
在MyFirebaseMessagingService 中为更新的令牌引入了新方法,以防万一它过期。
override fun onNewToken(token: String?) {
Log.d(TAG, "Refreshed token: $token")
// If you want to send messages to this application instance or
// manage this apps subscriptions on the server side, send the
// Instance ID token to your app server.
sendRegistrationToServer(token)
}
更多详情请访问fcm