订阅确认时 Amazon SNS SDK 无效参数异常 [英] Amazon SNS SDK Invalid Parameter exception on subscription confirmation
问题描述
我正在尝试使用此代码订阅 Android 用户以接收推送通知:
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);
}
}
但是,我在 confirmSubscription()
上得到以下异常:
However, I get the following exception on confirmSubscription()
:
10-15 15:39:59.453:D/(31274):意外异常:com.amazonaws.services.sns.model.InvalidParameterException:无效令牌(服务:AmazonSNS;状态代码:400;错误代码:无效的参数;请求 ID:742123aa-6dce-52f2-b2de-6f127516ec56)
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 ?
推荐答案
Android 端点(和所有移动端点)在 Subscribe
完成时自动确认.您不需要为这些端点调用 ConfirmSubscription
.
Android endpoints (and all mobile endpoints) are automatically confirmed when Subscribe
completes. You do not need to invoke ConfirmSubscription
for these endpoints.
这篇关于订阅确认时 Amazon SNS SDK 无效参数异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!