我想使用 Azure 事件中心在我的 android 应用程序中实现推送通知功能。作为一个新手,我不太清楚如何继续它。
我使用 Raspberry Pi 作为发件人(Azure 事件中心发件人),它按预期工作。为了接收从 Raspberry Pi 发送的消息,我希望我的 Android 设备能够处理它(作为 Azure 事件中心接收器)。
我遇到了广播接收器的概念,我认为可以在这里使用。需要输入是否我在正确的轨道上,如果提供一些示例,将不胜感激。
请提出实现此目标的最佳方法。
将事件从 Raspberry Pi 发送到 Azure 事件中心的代码:
from azure.servicebus import ServiceBusService
sbs = ServiceBusService(api_key["namespace"], shared_access_key_name=api_key["policy_name"], shared_access_key_value=api_key["policy_secret"])
sbs.send_event('eventhubname', '{ "DeviceId":"deviceId1", "Temperature":"10.0" }')
我参考了这些链接以在 .net 控制台应用程序中实现发送者和接收者,该应用程序按预期工作。需要在 Android 中实现相同的功能。
https://azure.microsoft.com/en-in/documentation/articles/event-hubs-csharp-ephcs-getstarted/
我还可以使用 Azue Python SDK ( https://pypi.python.org/pypi/azure-servicebus/0.20.1 )实现发件人