亚马逊SNS:如何使用Amazon .NET SDK通过令牌(registrationId)获得EndpointArn? [英] Amazon SNS: How to get EndpointArn by token(registrationId) using amazon .net sdk?

查看:703
本文介绍了亚马逊SNS:如何使用Amazon .NET SDK通过令牌(registrationId)获得EndpointArn?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用AWS .NET SDK获得EndpointArn通过注册ID。但我无法找到一个很好的办法做到这一点。

I am trying to get EndpointArn by registration id using aws .net sdk. But i couldn't find a nice way to do it.

我的第一次尝试运行CreatePlatformEndpointRequest具有相同registrationId,这与之前注册的SNS应用,客户端(安卓)发送。通过这种方式,AWS API为您提供了EndpointArn这个注册ID。

My first attempt was running CreatePlatformEndpointRequest with the same registrationId, which is registered to SNS Application before, sent by the client(android). With this way, aws api gives you the EndpointArn for this registration id.

<一个href="http://docs.aws.amazon.com/sns/latest/APIReference/API_CreatePlatformEndpoint.html">Amazon:该CreatePlatformEndpoint行为是幂等的,因此,如果请求者   已经拥有与同一设备令牌和属性的端点,   该端点的ARN是不创建新的端点返回。

Amazon: The CreatePlatformEndpoint action is idempotent, so if the requester already owns an endpoint with the same device token and attributes, that endpoint's ARN is returned without creating a new endpoint.

但是,如果你存储的东西CustomUserData之前,你需要发送相同的用户数据,以获得端点ARN这个注册ID,否则,你得到一个异常如下图所示。

But if you stored something to CustomUserData before you need to send the same user data to get endpoint arn for this registration id, otherwise you get an exception like below.

无效的参数:令牌原因:端点   {我的端点ARN}   已经存在具有相同令牌,但不同的属性。

Invalid parameter: Token Reason: Endpoint {My Endpoint ARN} already exists with the same Token, but different attributes.

我想我会用CreatePlatformEndpoint()不包含用户数据,当我需要端点阿恩的registrationId我会运行CreatePlatFormEndpoint只有这个注册ID。

I think i am going to use CreatePlatformEndpoint() without user data and when i need Endpoint Arn for a registrationId i will run CreatePlatFormEndpoint only with this registration id.

有另一种方法通过令牌比上面的解决方案更好地得到EndpointArn?

Is there another way to get EndpointArn by token better than the solution above ?

感谢你。

推荐答案

是存储ARN从CreatePlatformEndpoint在我们​​的应用程序数据库返回的端点。如果我们已经有一个给定的设备注册ID的终端ARN协会,我们然后调用

What we did is store the endpoint ARN returned from CreatePlatformEndpoint in our application database. If we already have an endpoint ARN association for a given device registration id, we then call

getEndpointAttributes传递从我们的数据库端点阿尔恩。如果返回结果,我们再检查是否标记为启用的端点,如果没有的话称setEndpointAttributes和设置键使能为true。

getEndpointAttributes passing in the endpoint arn from our database. If a result is returned, we then check if the endpoint is marked enabled and if not then call setEndpointAttributes and set key "Enabled" to "true".

不幸的是,看起来并不像Amazaon API提供了一个findBy方法,通过CustomUserData或令牌来查找,只提供名单的方法,列出所有现有的端点这对于大多数应用程序,如果是不够的有潜在的数千乃至数百万条目。这是几乎一样,如果API只写满足亚马逊的控制台界面的用例。

Unfortunately it doesn't look like Amazaon API offers a "findBy" method to look up by "CustomUserData" or "Token" and only has "list" methods that list all the existing endpoints which for most applications will not suffice if there are potentially thousands or millions of entries. It is almost as if API was written only to satisfy the Amazon Console UI use cases.

另外,请参阅亚马逊的文档,例如API请求和响应

Also, see Amazon docs for example API requests and responses

http://docs.aws.amazon.com/sns/最新/ API / API_GetEndpointAttributes.html http://docs.aws.amazon.com/sns/latest/api /API_SetEndpointAttributes.html

这篇关于亚马逊SNS:如何使用Amazon .NET SDK通过令牌(registrationId)获得EndpointArn?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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