问题是,如果用户卸载并安装该应用程序,它将生成一个新令牌,但是当用户更新我的应用程序时,我希望在他们打开我的应用程序时生成一个新令牌,因为昨天的更新使我损失了一些销售收入由于通知从未到达,我的客户需要卸载并安装我的应用程序!
我有这个代码
class MyFirebaseMessagingService: FirebaseMessagingService() {
override fun onNewToken(token: String) {
super.onNewToken(token)
val currentUser= FirebaseAuth.getInstance().currentUser?.uid
if(currentUser != null){
FirebaseFirestore.getInstance().collection("user").document(currentUser).update("deviceToken",token)
}
}
}
每次用户登录时,我也会更新实例ID,但我不知道为什么更新应用程序会使用户不再收到通知
此更新不会删除Firebase上的instanceId