gpt4 book ai didi

ios - 如何使用 iOS SDK 重新启用 Amazon SNS 终端节点?

转载 作者:可可西里 更新时间:2023-11-01 03:43:26 25 4
gpt4 key购买 nike

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

无论出于何种原因,我的端点有时似乎会设置为“false”——即使我知道它们是有效的端点(因为重新启用它们然后会向设备发送新的推送通知)。 There's a similar Stack Overflow question here - but no technical answer as to how to resolve the issue.

所以:我需要弄清楚如何将端点设置为已启用

only sparse Amazon documentation对于如何执行此操作,所以我知道的是我需要使用属性字典中的“启用”键/值。

我的代码片段如下所示:

AmazonSNSClient *sns = [AmazonClientManager sns];

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

SNSCreatePlatformEndpointResponse *endpointResponse = [sns createPlatformEndpoint:endpointPutRequest];

除了单行代码,它工作得很好,它将属性值“Enabled”设置为“true”。我已经尝试了所有这些组合:

[endpointPutRequest setAttributesValue:@"true" forKey:@"Enabled"];
[endpointPutRequest setAttributesValue:@"true" forKey:@"enabled"];
[endpointPutRequest setAttributesValue:@"True" forKey:@"Enabled"];

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

最佳答案

到目前为止,我发现在某些情况下,即使端点和 token 正确,端点属性也会变为 false

  1. 如果您已经使用 Production APNS 证书创建了亚马逊 sns 应用程序,但您尝试使用 SANDBOX APNS(即开发 APNS)注册您的设备,那么它将得到 false

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

  3. 当用户删除/卸载应用时

关于ios - 如何使用 iOS SDK 重新启用 Amazon SNS 终端节点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23700649/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com