Firebase云消息传递 - GCM规范ID仍然是必需的? [英] Firebase Cloud Messaging - Are GCM canonical IDs still necessary?

查看:107
本文介绍了Firebase云消息传递 - GCM规范ID仍然是必需的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读GCM中的规范ID,以及它们如何帮助纠正发送重复推送通知和安全性。但现在使用Firebase Cloud Messaging(FCM),这个问题是否仍然存在?



我现在注册的部分已经从开发者手中拿走了,我们只是等待令牌刷新,如下所示:

  public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {

@Override
public void onTokenRefresh(){
//获取更新的注册ID
String refreshedToken = FirebaseInstanceId.getInstance()。getToken();
Logger.d(刷新的FCM令牌:+ refreshedToken);
}
}

有关规范ID的一些信息可以在这里

解决方案::



我最近在Canonical ID上重新讨论了此主题,并得出以下结论。 p>

在FCM中,由于实例ID服务有效。简单来说,该服务的作用是每个App Instance只有一个有效标记。



如果旧标记过期(无论哪个原因),FCM会触发tokenRefresh事件,你会得到一个新的注册令牌,并且你也必须相应地处理它(在 onTokenRefresh())。






简短回答,是的。这仍然是必要的。 $ onTokenRefresh()方法预计会在实际刷新令牌时触发。从那里开发者有责任将注册令牌发送给应用服务器。



在您无法使用的情况下获取新的注册令牌(例如忘记保存它,删除它并且只有以前的注册令牌等),它可能会导致您(开发人员)向一个假定不再有效的注册令牌发送。那是Canonical IDs进来的时候。



我想你可以把Canonical IDs当作另一种安全措施,这样开发人员仍然可以获得有效的注册令牌。 FCM文档中提到了关于Canonical ID的详细信息(处理方式和内容)这里


I've been reading on canonical IDs in GCM and how they help to rectify sending duplicate push notifications and with security. But now with Firebase Cloud Messaging (FCM), does this issue still exist?

I am the registration part has been taken away from the developer now and we just wait for a token refresh as per below:

    public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {

    @Override
    public void onTokenRefresh() {
        // Get updated registration ID
        String refreshedToken = FirebaseInstanceId.getInstance().getToken();
        Logger.d("Refreshed FCM token: " + refreshedToken);
    }
}

Some info on canonical IDs can be found here.

解决方案

Update:

I recently revisited this topic on Canonical IDs and have concluded the following.

In FCM, it seems the Canonical IDs are no longer used (or at the very least extremely rarely) because of the way the Instance ID service works. To put it simply, the service works that there would only be one valid token per App Instance.

If the older token expires (for whichever reason), FCM triggers a tokenRefresh event where you would get a new registration token, and where you must also handle it accordingly (in onTokenRefresh()).


Short answer, Yes. It's still necessary.

The onTokenRefresh() method is expected to trigger whenever the token is actually refreshed. From there, it's the developer's responsibility to send the registration token towards an App Server.

BUT in an event where you weren't able to get a hold of the new registration token (e.g. forgot to save it, deleted it and only have the previous registration token, etc.), it may result to you (the developer) to send towards a supposed to be no longer valid registration token. That's when Canonical IDs come in.

I guess you can treat Canonical IDs as another safety measure so that developers can still get a hold of the valid registration token. Details about Canonical IDs (how it is handled and stuff) are mentioned in the FCM docs here.

这篇关于Firebase云消息传递 - GCM规范ID仍然是必需的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆