AWS SNS通过Cognito身份ID发布给特定用户 [英] AWS SNS Publish to specific User via Cognito Identity ID

查看:96
本文介绍了AWS SNS通过Cognito身份ID发布给特定用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在这里做的是,当特定用户是新添加的DynamoDB项的一部分时,通过SNS和APNS发送通知。我想将其发送给用户Cognito身份ID,而不是设备令牌。

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.

因此,在添加商品时应触发Lambda,然后浏览Cognito列表身份ID,也是项目的一部分。

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.

然后Lambda应该将推送通知发布到每个Cognito身份ID。

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

所有设备都在sns中注册为端点。我还将Cognito身份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.

但是我没有找到直接向Cognito身份ID发送通知的方法。我是否必须为每个用户添加一个主题并将通知发送给该主题?还是我必须存储另一个DynamoDB表以将Cognito身份ID映射到设备令牌?如果有人知道更简单但又不太昂贵的方法,那就太好了!

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!

谢谢!

推荐答案

如果要通过SNS将推送通知发送到APNS或GCM,则首先需要为每个为推送通知注册的设备令牌创建一个SNS平台端点。拥有SNS端点后,您需要在用户表或其他映射表中使用Cognito身份ID映射该端点。

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.

将新项目添加到DynamoDB后,事件处理程序(Lambda)将需要将传入的Cognito身份ID映射到用户表中的SNS平台端点,然后它可以直接发布到该端点。

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.

您无需创建SNS主题即可将Push发送到各个端点。

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

这篇关于AWS SNS通过Cognito身份ID发布给特定用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆