简体   繁体   English

如何设置 AWS SNS 以向 Android 设备列表发送推送通知

[英]How to set up AWS SNS to send Push notifications to list of Android devices

I have followed the documentation of AWS SNS push notification.我遵循了 AWS SNS 推送通知的文档。 http://docs.aws.amazon.com/sns/latest/dg/sns-dg.pdf http://docs.aws.amazon.com/sns/latest/dg/sns-dg.pdf

I have successfully send Push notification to android device via GCM, But I am sending only one android device at a time.我已经通过 GCM 成功地将推送通知发送到 android 设备,但我一次只发送一个 android 设备。 (To sending multiple devices I have to run the same code again and again via for loop) (要发送多个设备,我必须通过 for 循环一次又一次地运行相同的代码)

So my question is : Is there any way to send push notification for multiple android device at the same time.所以我的问题是:有没有办法同时为多个 android 设备发送推送通知。 (Means is there any API, any method who took multiple device token (registration id) as a List or Array and send the push notification to all Android device) (意味着是否有任何 API,任何将多个设备令牌(注册 ID)作为列表或数组并将推送通知发送到所有 Android 设备的方法)

Thanks谢谢

Subscribe the devices via the SNS client to a topic and then publish your message to the topic.通过 SNS 客户端为设备订阅主题,然后将您的消息发布到该主题。 All devices subscribed to this topic will receive the notification.订阅此主题的所有设备都会收到通知。

Subscribing to a topic:订阅主题:

String subscriptionId = snsClient.subscribe(new SubscribeRequest()
            .withEndpoint(endpointId)
            .withProtocol("application")
            .withTopicArn(topicId)
            ).getSubscriptionArn();     

Publish notification in a topic:在主题中发布通知:

PublishResult result = snsClient.publish(topicArn, message);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM