我有一个应用程序可以管理第三方服务器列表并可以轮询它们以获取信息。这些服务器应该彼此独立(并且可能不受我的控制)。
现在我想实现 c2dm 通知以避免持续的主动轮询。
第三方服务器将能够发布他们的 senderId
并允许我的客户端在向谷歌注册后向他们发送 C2DM registrationId
。
现在我的问题是:是否可以从同一个应用程序包为多个 c2dm 发件人注册?如果是这样,我将如何区分注册(尤其是注销)过程,以便我可以更新正确的本地服务器配置条目?
我找到的唯一资源是 this google groups thread ,但一段时间没有得到答复。我希望你能帮上忙。
注意:这只是关于注册的。在发送消息时,第三方服务器可以注入(inject)他们的服务器名称,以便消息处理程序可以区分它们。但是谷歌服务器的注册过程似乎没有给我一个选项,可以将用户定义的信息传回我的 BroadcastReceiver
最佳答案
由 Costin Manolache(Google 软件工程师)撰写:
An app can't register 2 different sender IDs - there is a single record for an (android-id + app id), the second registration will replace the first one and the first sender won't be able to send.
In any case - this is not a 'supported' feature right now, but sounds reasonable.
Please don't use one sender account shared with multiple customers - besides TOS you may run into other problems.
我遇到了同样的问题。 一个客户端在多个服务器上有多个帐户,应在其拥有的所有服务器上注册以接收通知。
关于android - C2DM : Can I register for multiple sender-ids in the same app?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5128051/