android - 当所有应用程序都备份到新手机时,FCM 令牌不会更新
问题描述
恢复备份数据后,我希望onTokenRefresh
调用该方法,但事实并非如此。相反,当我第一次运行应用程序时,会调用该方法。
由于更新后的token无法在推送服务器上更新,因此新手机收不到FCM通知。
onTokenRefresh
备份应用程序时有没有办法强制?或者,是否有应用程序安装回调?
解决方案
onTokenRefresh()现在已弃用。
您需要覆盖新方法 onNewToken()
/**
* Called if InstanceID token is updated. This may occur if the security of
* the previous token had been compromised. Note that this is called when the InstanceID token
* is initially generated so this is where you would retrieve the token.
*/
@Override
public void onNewToken(String token) {
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);
}
推荐阅读
- javascript - 如果计数器的值为 0,如何隐藏我的徽章?
- sql - 无法打开物理文件。操作系统错误 5:“5(拒绝访问。)”
- javascript - ReactJS如何在成功时显示一个常量函数?
- amazon-web-services - ECS 通过容量提供程序扩展到 ASG 的最小容量
- sql - SQL 查询效率 - 使用左外连接 VS 嵌套选择语句
- r - R:有条件地将数据从一个数据帧提取到另一个数据帧
- node.js - 成功回调后我应该关闭oracle连接吗?
- python - 如何拟合 Keras 模型关于火车形状的误差?
- php - MySql可以在一张表中设置一个主键的两个外键吗?
- java - 当伊甸园已满但其中的所有对象都还活着时会发生什么