2016-10-21 1 views
0

amazonでsnsモバイルプッシュを使用してプッシュ通知を送信しています。デバイストークンをamazonに登録するにはCreatePlatformEndpointを使用しています。Amazon sns mobile push CreatePlatformEndpointは、同じトークンとユーザーデータを持つ複数のエンドポイントを作成します。

Amazonの文書(http://docs.aws.amazon.com/sns/latest/api/API_CreatePlatformEndpoint.html)を1として:

CreatePlatformEndpointアクションが冪等なので、要求者がすでに同じトークンデバイスおよび属性を持つエンドポイントを所有している場合、そのエンドポイントのARNは、新しいエンドポイントを作成せずに返されます。

私はCreatePlatformEndpointを使用するとき、私は同じ属性(ユーザーデータ)で同じトークンを複数回(最大3回)登録することができます。この動作を理解できません。

答えて

0

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 

あなたは、このリンクで見ることができます: Create a Platform Endpoint and Manage Device Tokens

関連する問題