我正在尝试使用亚马逊网络服务.net软件开发工具包通过注册id获取EndpointArn。但是我找不到一个好的方法去做。
我的第一次尝试是用同样的registrationId运行CreatePlatformEndpointRequest,它之前注册到了SNS Application,由客户端(安卓)发送。通过这种方式,aws api会为您提供此注册id的EndpointArn。
ARN : CreatePlatformEndpoint操作是幂等的,因此如果请求者已经拥有一个具有相同设备令牌和属性的端点,则返回该端点的
,而不创建新端点。
但是,如果您在需要发送相同的用户数据以获取此注册id的端点arn之前将某些内容存储到CustomUserData,否则会得到如下所示的异常。
参数无效:令牌原因:终结点{My Endpoint ARN}已存在,具有相同的令牌,但属性不同。
我想我将使用没有用户数据的CreatePlatformEndpoint(),当我需要一个registrationId的Endpoint Arn时,我将只使用这个注册id运行CreatePlatFormEndpoint。
有没有比上面的解决方案更好的按令牌获取EndpointArn的方法?
谢谢。
发布于 2015-09-21 04:57:12
我们所做的是将从CreatePlatformEndpoint返回的端点ARN存储在我们的应用程序数据库中。如果已经有给定设备注册id的端点ARN关联,则调用
从我们的数据库传入端点arn的getEndpointAttributes。如果返回结果,我们将检查端点是否被标记为enabled,如果没有,则调用setEndpointAttributes并将键"Enabled“设置为"true”。
不幸的是,Amazaon API看起来不像是通过"CustomUserData“或"Token”来查找的"findBy“方法,而只是列出了所有现有端点的" list”方法,对于大多数应用程序来说,如果可能有数千或数百万个条目,这些方法是不够的。几乎就像编写API只是为了满足Amazon控制台UI用例一样。
此外,有关API请求和响应的示例,请参阅Amazon文档
http://docs.aws.amazon.com/sns/latest/api/API_GetEndpointAttributes.html http://docs.aws.amazon.com/sns/latest/api/API_SetEndpointAttributes.html
发布于 2015-12-11 16:36:03
根据亚马逊网络服务在https://mobile.awsblog.com/post/Tx223MJB0XKV9RU/Mobile-token-management-with-Amazon-SNS上的博客,他们还建议应用程序端存储ARN。
retrieve the latest token from the mobile OS
if (endpoint arn not stored)
# first time registration
call CreatePlatformEndpoint
store returned endpoint arn
endif
call GetEndpointAttributes on the endpoint arn
if (getting attributes encountered NotFound exception)
#endpoint was deleted
call CreatePlatformEndpoint
store returned endpoint arn
else
if (token in endpoint does not match latest) or
(GetEndpointAttributes shows endpoint as disabled)
call SetEndpointAttributes to set the
latest token and enable the endpoint
endif
endif
https://stackoverflow.com/questions/22501373
复制相似问题