Ken*_*ent 8 cocoa-touch amazon-web-services ios
使用适用于iOS的AWS SDK v2.0.8
快速提问:
我如何[snsClient deleteEndpoint:request]
,我不知道这个端点的阿尔恩?我确实有deviceToken.
详情:
我Token Reason: Endpoint arn:aws:sns:...c6 already exists with the same Token, but different attributes
尝试为iPhone创建端点时收到错误:
// 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;
}];
Run Code Online (Sandbox Code Playgroud)
当我创建端点时,我没有设置attributes
,我customUserData
根据可以更改的客户端数据进行设置.在它的SDK文档中customUserData
说:与端点关联的任意用户数据.Amazon SNS不使用此数据.数据必须采用UTF-8格式且小于2KB.
当我从SNS控制台删除端点时,我可以获得一个新端点.那么当我不知道这个端点的arn时,如何deleteEndpoint呢?我可以在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>
]
Run Code Online (Sandbox Code Playgroud)
我可以得到什么(BFTask*任务).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)
Run Code Online (Sandbox Code Playgroud)
**更新2014-10-01**
我的开发iPad在更新到iOS 8.0.2后才开始这样做.我确实将版本号添加到customUserData
- 但亚马逊SNS不使用此字段......对吗?
**更新2014-01-01 19:06 GMT-07:00**
添加task.error.userInfo
到错误块.我会解析消息并在出现时删除端点.一个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 "
);
}
Run Code Online (Sandbox Code Playgroud)