我正在使用amazon sns移动推送发送推送通知。为了向amazon注册设备令牌,我使用CreatePlatformEndpoint。
根据amazon文档(http://docs.aws.amazon.com/sns/latest/api/API_CreatePlatformEndpoint.html):
CreatePlatformEndpoint操作是幂等的,因此如果请求者已经拥有具有相同设备令牌和属性的端点,则返回该端点的ARN,而无需创建新端点。
但是当我使用CreatePlatformEndpoint时,我能够多次(最多3次)使用相同的属性(用户数据)注册相同的令牌。无法理解此行为
chetna bhandari,
我有这个问题。我有一个iOS平台应用程序(APNS)和另一个Android (GCM)。对于iOS, createPlatformEndpoint方法工作得很好。但是对于Android,使用相同的令牌创建多个端点(最多3个,就像你一样)。下次我尝试使用createPlatformEndpoint时,抛出一个异常。
正确的方法是将端点存储在应用程序中。如果还没有存储,创建并存储则伪代码为:
retrieve the latest device token from the mobile operating system
if (the platform endpoint ARN is not stored)
# this is a first-time registration
call create platform endpoint
store the returned platform endpoint ARN
endif
call get endpoint attributes on the platform endpoint ARN
if (while getting the attributes a not-found exception is thrown)
# the platform endpoint was deleted
call create platform endpoint with the latest device token
store the returned platform endpoint ARN
else
if (the device token in the endpoint does not match the latest one) or
(get endpoint attributes shows the endpoint as disabled)
call set endpoint attributes to set the latest device token and then
enable the platform endpoint
endif
endif
你可以在这个链接中看到:创建平台端点并管理设备令牌