英文:
Sending SNS push notification message to multiple devices
问题
我需要使用aws-sdk-go
库将SNS推送通知发送到多个设备,传递设备令牌数组。
目前,我使用以下步骤将推送消息发送到SNS:
创建端点:
pl, err := svc.CreatePlatformEndpoint(&sns.CreatePlatformEndpointInput{
PlatformApplicationArn: aws.String(topic),
Token: aws.String(n.DeviceToken), // 只有一个设备令牌
})
向端点发送消息:
params := &sns.PublishInput{
Message: aws.String(payload),
TargetArn: aws.String(*pl.EndpointArn),
MessageStructure: aws.String("json"),
}
我还没有找到一种只使用一个请求向多个设备发送一条推送消息的方法。这种可能吗?
像这个例子一样说明:
pl, err := svc.CreatePlatformEndpoint(&sns.CreatePlatformEndpointInput{
PlatformApplicationArn: aws.String(topic),
Token: []aws.String{token01, token02, token03}, // 设备令牌数组
})
英文:
I need to send SNS push notification to multiple devices passing the array of device tokens using aws-sdk-go
lib.
Currently I'm sending the push message to SNS using this steps:
Creating the endpoint:
pl, err := svc.CreatePlatformEndpoint(&sns.CreatePlatformEndpointInput{
PlatformApplicationArn: aws.String(topic),
Token: aws.String(n.DeviceToken), // just one device token
})
Sending the message to endpoint:
params := &sns.PublishInput{
Message: aws.String(payload),
TargetArn: aws.String(*pl.EndpointArn),
MessageStructure: aws.String("json"),
}
I have not seen a way to send one push message to multiple devices using just one request. Is it possible?
Like this example to illustrate:
pl, err := svc.CreatePlatformEndpoint(&sns.CreatePlatformEndpointInput{
PlatformApplicationArn: aws.String(topic),
Token: []aws.String{token01, token02, token03}, //array of device tokens
})
答案1
得分: 3
解决方案:我创建了一个主题,订阅了这个主题的设备,并向主题发送了推送消息。
英文:
Solution: I solved creating a topic, subscribing the devices in this topic and sending the push message to the topic.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论