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

查看:19
本文介绍了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天全站免登陆