使用适用于iOS的AWS SDK v2.0.8
快速提问:
当我不知道这个终点时,我如何[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
。在customUserData
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>
]
中,它说:与端点关联的任意用户数据。 Amazon SNS不使用此数据。数据必须采用UTF-8格式且小于2KB。
当我从SNS控制台删除端点时,我可以获得一个新端点。那么当我不知道这个端点时,如何删除Endpoint?我可以在AWS日志记录中看到arn,但不能在BFTask *错误对象中看到。
我在SDK docs看到了ruby解决方案,但我没有看到读取消息的方法,ruby示例从异常中读取消息,task.exception == nil在我的情况下。我从AWS详细日志记录中收到了:
使用AWS日志记录:
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)
我能得到什么(BFTask * task).error:
customUserData
**更新2014-10-01 **
我的开发iPad在更新到iOS 8.0.2后才开始这样做。我做将版本号添加到task.error.userInfo
- 但Amazon SNS不使用此字段......对吗?
**更新2014-01-01 19:06 GMT-07:00 **
在错误块中添加了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 "
);
}
中的一个选项可以覆盖此错误,更新端点并返回端点会很好;)
控制台现在有:
{{1}}
答案 0 :(得分:1)
userInfo
的{{1}}属性应包含错误XML的字典表示。