问题
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