Amazon SNS SDK Invalid Parameter exception on subscription confirmation

吃可爱长大的小学妹 提交于 2019-11-30 20:27:57

问题


I'm trying to subscribe an Android user to receive push notifications using this code:

 public static void subscribeToTopic(final String topicArn, String EndpointArn) {
        SubscribeRequest request = new SubscribeRequest(topicArn, "application" , EndpointArn);
        SubscribeResult response = getInstance().subscribe(request);
        ConfirmSubscriptionRequest confirmation = new ConfirmSubscriptionRequest(topicArn, response.getSubscriptionArn());
        try {
            getInstance().confirmSubscription(confirmation);
        } catch (Exception e) {
            Log.d(TAG, "UNEXPECTED EXCEPTION: " + e);
        }
    }

However, I get the following exception on confirmSubscription():

10-15 15:39:59.453: D/(31274): UNEXPECTED EXCEPTION: com.amazonaws.services.sns.model.InvalidParameterException: Invalid token (Service: AmazonSNS; Status Code: 400; Error Code: InvalidParameter; Request ID: 742123aa-6dce-52f2-b2de-6f127516ec56)

However, the subscription IS a success and I succeeded to send push notifications to the app.

Any idea why I get this error ? Is it because confirmation is unnecessary on for this protocol ?


回答1:


Android endpoints (and all mobile endpoints) are automatically confirmed when Subscribe completes. You do not need to invoke ConfirmSubscription for these endpoints.



来源:https://stackoverflow.com/questions/26376492/amazon-sns-sdk-invalid-parameter-exception-on-subscription-confirmation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!