如何使用iOS SDK重新启用Amazon SNS端点?

bry*_*ark 6 push-notification amazon-web-services amazon-sns ios

我正在使用Amazon SNS向我的iOS应用程序发送推送通知.

无论出于何种原因,我的端点偶尔会被设置为"假" - 即使我知道它们是有效的端点(因为重新启用它们然后向设备发送新的推送通知).这里有类似的Stack Overflow问题 - 但没有关于如何解决问题的技术答案.

所以:我需要弄清楚如何将端点设置为enabled.

只有稀稀拉拉亚马逊的文档如何做到这一点,所以我知道的是,我需要在属性字典使用"启用"键/值.

我的代码片段如下所示:

AmazonSNSClient *sns = [AmazonClientManager sns];

SNSCreatePlatformEndpointRequest *endpointPutRequest = [SNSCreatePlatformEndpointRequest new];
endpointPutRequest.platformApplicationArn = kBXTAWSAppARN;
endpointPutRequest.token = deviceToken;
[endpointPutRequest setAttributesValue:@"True" forKey:@"Enabled"];

SNSCreatePlatformEndpointResponse *endpointResponse = [sns createPlatformEndpoint:endpointPutRequest];
Run Code Online (Sandbox Code Playgroud)

除了单行代码之外,这种方法非常有效,它将attributesValue"Enabled"设置为"true".我尝试了所有这些组合:

[endpointPutRequest setAttributesValue:@"true" forKey:@"Enabled"];
[endpointPutRequest setAttributesValue:@"true" forKey:@"enabled"];
[endpointPutRequest setAttributesValue:@"True" forKey:@"Enabled"];
Run Code Online (Sandbox Code Playgroud)

......但它们都不起作用.编写这行代码的正确方法是什么?我应该以某种方式使用BOOL吗?整数?

use*_*079 5

到目前为止,我发现有一些条件,即使端点和令牌是正确的,endPoint属性也会变为false

  1. 如果您使用生产APNS证书创建了亚马逊sns应用程序,但是您尝试使用SANDBOX APNS(即开发APNS)注册您的设备,那么它将会出错

  2. 当用户关闭手机设置中的通知时,Apple APNS也会禁用影响亚马逊sns的标志.每当用户再次启用通知时,您已将令牌重新发送到amazon以设置属性,即需要在客户端处理

  3. 当用户删除/取消应用程序时