FCM |多个发件人 ID [英] FCM | Multiple Sender ID

本文介绍了FCM |多个发件人 ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从 GCM 转向 FCM.

在 GCM 中,我们可以为多个发送者 id 调用 getToken() 方法,如下所示:

String senderIds = "112233445566,889922338899";String token = instanceID.getToken(senderIds,GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);

问题 1 - 进入 FCM 后,它会保持不变还是我需要进行任何更改才能获得多个发件人 ID 的令牌?

来自这个 参考,我知道我可以为每个发件人 ID 调用 getToken("senderIds1", "FCM"),但我希望在进入 FCM 时更改最少的代码.

Q2 以下是否适用于 FCM(与 GCM 相同)或者我必须调用 getToken("senderIds1", "FCM");getToken("senderIds2", "FCM")?

getToken("senderIds1, senderIds2", "FCM")

解决方案

更多地了解这个功能——扫描文档和查看旧帖子——我决定更新这个答案.由于行为本身在 FCM 正式发布之前就已经存在,很多东西已经在服务中(在幕后)中更新(一些已弃用).这方面的一个例子是回到 C2DM 到 GCM 的迁移,其中 令牌是'不可互操作.

对于通过传递逗号分隔的 senderIds 来使用 getToken(),鉴于它没有记录或在任何官方 FCM 文档或声明中被建议/提及,最好避免使用它们,而是继续官方程序——通过使用 getToken("senderId", "scope") 对于每个 发件人并将每个令牌保持为需要.

通过传递逗号分隔的 senderIds 选择仍然使用 getToken() 可能会在未来产生意想不到的行为,因此我强烈建议开发人员继续执行重复帖子中建议的过程.>

Moving to FCM from GCM.

In GCM, we can call getToken() method for multiple sender ids as below:

String senderIds = "112233445566,889922338899";
String token = instanceID.getToken(senderIds,
                        GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);

Q1 - After moving into FCM, will it remain same or I need to make any changes in order to get the token for multiple sender ids?

From this reference, I know that I can call getToken("senderIds1", "FCM") for each sender Id, but I want minimum code changes while moving into FCM.

Q2 Will below work for FCM (same like GCM) or I have to call getToken("senderIds1", "FCM"); getToken("senderIds2", "FCM")?

getToken("senderIds1, senderIds2", "FCM") 

解决方案

Looking more into this function -- scanning the documents and viewing old posts -- I've decided to update this answer. Since the behavior itself existed way before FCM was officially released, a lot of things have already been updated (some deprecated) in the service (under the hood). An example of this is going way back to C2DM to GCM migration, the part where the tokens weren't interoperable was stated.

For using getToken() by passing comma-separated senderIds, seeing as it is not documented or is advised/mentioned in any official FCM documentation or statements, it is best to avoid using them and instead proceed with the official procedure -- by using getToken("senderId", "scope") for each sender and maintaining each of those tokens as needed.

Choosing to still use getToken() by passing comma-separated senderIds may probably produce unexpected behaviors in the future, so I strongly encourage developers to proceed with the suggested procedure in the duplicate post.

这篇关于FCM |多个发件人 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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