AWS SNS Publish to specific User via Cognito Identity ID

落花浮王杯 提交于 2019-12-21 20:02:01

问题


What I'm trying to do here is sending a notification via SNS and APNS when a specific user is part of a newly added DynamoDB Item. I want to send it to the users Cognito Identity ID, not to device token.

So Lambda should be triggered when the item is added and then go through a list of Cognito Identity IDs, which is also part of the item.

Then Lambda is supposed to publish the push notifications to each Cognito Identity ID.

All the devices are registered as endpoints within sns. I also keep the Cognito Identity ID in the "user data" row for the endpoint.

But i didn't find a way to send notifications directly to a Cognito Identity ID. Do i have to add a topic for each user and send the notification to that topic? Or do i have to store another DynamoDB table to map Cognito Identity IDs to device tokens? It would be great if someone knew an easier and not too expensive way!

Thank you!


回答1:


If you are sending Push Notifications via SNS to APNS or GCM then you first need to create an SNS Platform Endpoint for each device token registered for Push Notifications. Once you have an SNS Endpoint, you'll need to map that endpoint with the Cognito Identity ID in the user table or another mapping table.

When a new item is added to DynamoDB, the event handler (Lambda) will need to map the incoming Cognito Identity ID to the SNS Platform Endpoint in the user table and then it can direct publish to that one endpoint.

You do not need to create an SNS Topic for sending Push to individual endpoints.



来源:https://stackoverflow.com/questions/37439656/aws-sns-publish-to-specific-user-via-cognito-identity-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!