ios - AWS SNS 错误参数无效 : Token Reason: Endpoint xxx already exists with the same Token, 但属性不同

标签 ios cocoa-touch amazon-web-services

使用适用于 iOS v2.0.8 的 AWS 开发工具包

快速提问:

当我不知道此端点的 arn 时,如何[snsClient deleteEndpoint:request]?我有 deviceToken。

详细信息:

当我尝试为我的 iPhone 创建端点时,我收到错误 Token Reason: Endpoint arn:aws:sns:...c6 already exists with the same Token, but different attributes:

// Async call to create the platform endpoint
[[[_awsSnsClient createPlatformEndpoint:request] continueWithSuccessBlock:^id(BFTask *task) {
    // success
    _awsPlatformEndpoint = task.result; // Save off the endpoint data
    [self awsUsubscribeAllSubscriptions];
    return nil;
}] continueWithBlock:^id(BFTask *task) {
    if (task.error) {
        // failed with error
        ALog(@"Error: Code:%li localizedDesc:%@ Exception:%@", (long)task.error.code, task.error.localizedDescription, task.exception);
        if(task.error.code == 7) {
            // delete offending endpoint and create it again?
        }
    }
    return nil;
}];

当我创建端点时,我没有设置 attributes,我确实根据可以更改的客户端数据设置了 customUserData。在SDK docs对于 customUserData,它表示:要与端点关联的任意用户数据。 Amazon SNS 不使用此数据。数据必须为UTF-8格式且小于2KB。

当我从 SNS 控制台删除端点时,我可以获得一个新的端点。那么当我不知道这个端点的 arn 时,我该如何删除端点呢?我可以在 AWS 日志记录中看到 arn,但在 BFTask* 错误对象中看不到。

我在 19551067 看到了 ruby 解决方案,但我看不到读取消息的方法,ruby 示例从异常中读取消息,在我的例子中是 task.exception == nil。我从 AWS 收到详细日志记录:

使用 AWS 日志记录:

2014-10-01 06:48:54.489 myApp[1665:1345740] AWSiOSSDKv2 [Verbose] AWSURLResponseSerialization.m line:244 | -[AWSXMLResponseSerializer responseObjectForResponse:originalRequest:currentRequest:data:error:] | Response body: [<ErrorResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
  <Error>
    <Type>Sender</Type>
    <Code>InvalidParameter</Code>
    <Message>Invalid parameter: Token Reason: Endpoint arn:aws:sns:us-west-2:245211809793:endpoint/APNS_SANDBOX/myApp-Dev/7bxxx-xxxx-xxxx-xxxc6 already exists with the same Token, but different attributes.</Message>
  </Error>
  <RequestId>d874ac10-e6de-5a4d-805e-e0b6ee58e5b7</RequestId>
</ErrorResponse>
]

我可以从 (BFTask* task).error 中得到什么:

2014-10-01 06:48:54.494 myApp[1665:1345740] __46-[AppDelegate_Shared awsStartWithDeviceToken:]_block_invoke1279 [Line 3558] Error: 
  Code:7 
  localizedDesc:The operation couldn’t be completed. (com.amazonaws.AWSSNSErrorDomain error 7.)
  Exception:(null)

** 更新 2014-10-01 **

我的开发版 iPad 在更新到 iOS 8.0.2 后就开始这样做了。我确实将版本号添加到 customUserData - 但 Amazon SNS 不使用此字段...对吗?

** 更新 2014-01-01 19:06 GMT-07:00 **

task.error.userInfo 添加到错误 block 。当出现这种情况时,我将解析消息并删除端点。 AWSSNSCreatePlatformEndpointInput 中的一个选项可以覆盖此错误、更新端点并返回端点;)

谢谢!

控制台现在有:

2014-10-01 18:58:50.836 iFlightBag[1862:1493821] __46-[AppDelegate_Shared     awsStartWithDeviceToken:]_block_invoke1281 [Line 3559] Error: 
Code:7 
localDesc:The operation couldn’t be completed. (com.amazonaws.AWSSNSErrorDomain error 7.) 
Exception:(null) 
userInfo:{
    Code = InvalidParameter;
    Message = "Invalid parameter: Token Reason: Endpoint arn:aws:sns:us-west-2:245211809793:endpoint/APNS_SANDBOX/LevelFlightMobile-Dev/7b70d2c4-846e-3afd-a1ba-eedaa00f7ac6 already exists with the same Token, but different attributes.";
    Type = Sender;
    "__text" =     (
        "\n    ",
        "\n    ",
        "\n    ",
        "\n  "
    );
}

最佳答案

task.erroruserInfo 属性应该包含错误 XML 的字典表示。

关于ios - AWS SNS 错误参数无效 : Token Reason: Endpoint xxx already exists with the same Token, 但属性不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26144103/

相关文章:

ios - 当应用程序从后台恢复时,在停止的地方恢复动画

ios - 使用 cocoapods 分发已编译的 .framework

iphone - 如何自定义我的 Tabbar Controller 图标(背景图像)?

ios - UITableViewCell 之间的间距有多高?

ios - 将标记 infoWindow 添加到 Mapbox 注释

objective-c - 调整大小时淡入 UIView 阴影

c# - 如何使用 SDK 删除 AWS EC2 中的图像 (AMI)?

ios - VoiceOver 焦点将 UICollectionView 重置为第一个条目?

amazon-web-services - 是否可以使用 CloudFormation 重新创建 AWS 资源?

amazon-web-services - AWS : Unused Elastic IP charges