如何使用 GCM(Google Cloud Messenger)注册基于 python 的客户端以获取设备的 registration_id?
Posted
技术标签:
【中文标题】如何使用 GCM(Google Cloud Messenger)注册基于 python 的客户端以获取设备的 registration_id?【英文标题】:How do you register a python-based client with GCM (Google Cloud Messenger) to get a registration_id for the device? 【发布时间】:2015-01-21 19:53:57 【问题描述】:我一直在尝试弄清楚如何使用以下 python 包之一创建一个基于 python 的客户端,该客户端能够通过 Google Cloud Messenging接收基于 XMPP 的消息。
https://github.com/geeknam/python-gcm
https://github.com/daftshady/py-gcm
https://pypi.python.org/pypi/gcm-client/
https://github.com/pennersr/pulsus
据我所知,(e.g., the documentation for gcm-client),这些包可以向registration_id
标识的其他客户端发送消息。但是,我首先如何获得每个客户的注册 ID?换句话说,我如何注册我正在创建的客户端应用程序以便它可以接收消息?
在我看来,这些并不是客户端本身,而只是可用于向客户端推送消息的库。我希望我错了,只是错过了一个关键概念。
【问题讨论】:
运气好吗? 我最终还是弄明白了,但很抱歉我不记得怎么弄了,也没有代码。它参与了。抱歉,我无法提供更多帮助。请查看我对下面 so_jin_ee 的回复以获得一个小提示,但您可能已经看到了... 是的,我看到了。但我不想使用java方法。并且答案中的链接已过期。感谢您的回复:) 【参考方案1】:每个客户端应用程序都必须调用getRegistrationId()
来获取一次注册ID。然后他们可以接收消息。更详细的函数调用是here
我希望这能让您对客户端设备有所了解。 :)
【讨论】:
谢谢,但我上面链接的库都没有提供调用该函数的方法。我已经求助于使用pyjnius来调用java方法(比如你提到的那个)。以上是关于如何使用 GCM(Google Cloud Messenger)注册基于 python 的客户端以获取设备的 registration_id?的主要内容,如果未能解决你的问题,请参考以下文章
Google Cloud端点模块与GCM的Google云端模块?
Google Cloud Messaging (GCM) 可以与 Kindle Fire 搭配使用吗?
ios Google Cloud Messaging (GCM) 未收到远程通知
Google Cloud Message (GCM) sent android is Error inValid Register