Amazon web services 获得;“已禁用”;来自亚马逊社交网站
我正在使用亚马逊SNS。通知工作正常,但有时会出现以下错误:Amazon web services 获得;“已禁用”;来自亚马逊社交网站,amazon-web-services,amazon-sns,Amazon Web Services,Amazon Sns,我正在使用亚马逊SNS。通知工作正常,但有时会出现以下错误: { "message": "Endpoint is disabled", "code": "EndpointDisabled", "name": "EndpointDisabled", "statusCode": 400, "retryable": false } 也许你知道原因。根据这意味着端点被禁用 发件人: Enabled--启用/禁用向端点传递的标志。当通知服务向SNS指示端点无效时,
{
"message": "Endpoint is disabled",
"code": "EndpointDisabled",
"name": "EndpointDisabled",
"statusCode": 400,
"retryable": false
}
也许你知道原因。根据这意味着端点被禁用
发件人:
Enabled--启用/禁用向端点传递的标志。当通知服务向SNS指示端点无效时,消息处理器将此设置为false。用户可以将其设置回true,通常在更新令牌之后
本例中的“通知服务”指的是谷歌的GCM、苹果APNS或亚马逊的ADM。到目前为止,我发现了三个原因:
- 有时我们会混合来自沙盒应用程序的代币
- 用户在电话设置中关闭通知
- 用户已卸载该应用程序
这些是关于iphone/ipad的。如果出现错误
端点被禁用
,请使用下面的代码启用端点,然后使用Amazon凭据推送通知:
*//Enable Device*
var sns = new AmazonSimpleNotificationServiceClient("AwsAccesskeyId", "AwsSecrteAccessKey", RegionEndpoint.USWest1);
Dictionary<string, string> objDictCheckEndpointEnable = new Dictionary<string, string>();
objDictCheckEndpointEnable.Add("Enabled", "False");
sns.SetEndpointAttributes(new SetEndpointAttributesRequest
{
Attributes = objDictCheckEndpointEnable,
EndpointArn = "AwsEndPointArn" //This is Device End Point Arn
});
*//End*
*//启用设备*
var sns=新的Amazon简化服务客户端(“AwsAccesskeyId”、“AwsSecrteAccessKey”、RegionEndpoint.USWest1);
Dictionary objDictCheckEndpointEnable=新字典();
objDictCheckEndpointEnable.Add(“Enabled”、“False”);
sns.SetEndpointAttributes(新的SetEndpointAttributesRequest
{
Attributes=objDictCheckEndpointEnable,
EndpointArn=“AwsEndPointArn”//这是设备端点Arn
});
*//结束*
您可以创建一个新的SNS主题,例如推送通知失败
,然后将您的APNS/APNS\u沙盒应用程序的“传递失败”事件与之关联。通过电子邮件(并确认)订阅该事件,您将获得有关故障的有用调试信息。这一切都可以通过SNS控制台完成,不需要API调用来执行
订阅此SNS主题的HTTP端点并记录所有交付失败可能是值得的,这样您就有了历史数据来处理和调试生产问题
例如,“与端点关联的平台令牌无效”的传递FailureMessage
,表示您正在从APNS\u沙箱向APNS注册设备发送消息,反之亦然。这可能意味着您的生成系统具有错误的APNS设置。(我们有一个令人沮丧的问题,开发人员使用APNS_SANDBOX构建的二进制文件,而TestFlight构建的二进制文件使用APNS进行本地测试和QA,这正是我走上这条道路的原因。)对于我来说,我得到的是“与端点关联的平台令牌无效”,因为我的SNS平台应用程序端点设置不正确。特别是,SNS控制台没有从my.p12文件中正确读取凭据,即使它包含正确的证书和私钥。基于的解决方案是创建第二个.p12文件,其中包含证书而没有密钥。我从第一个.p12文件加载凭据,然后从第二个.p12文件加载凭据。当我这样做时,我可以看到证书字符串发生了变化,之后我就没有问题了
如果您正在创建生产端点,SNS将警告您证书不匹配,但它不会对开发端点进行此类检查。只有当您得到平台令牌错误时,您才能知道端点被阻塞
我当然希望这能帮助其他人,因为这会让我分心。我也有同样的问题。
这就是我所做的:
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
我希望这能帮那些遇到与我相同问题的人节省1/2天的工作时间!:) 采取严厉措施前的快速检查表:
在我的例子中,我使用第三方SSL工具生成了CSR。我从Apple developer portal获得了有效的证书,但没有私钥。然后我尝试了Windows的证书工具导出,但没有成功。浪费时间。开始吧
-----BEGIN RSA PRIVATE KEY-----
-----END RSA PRIVATE KEY-----
- (void)getEndpointDetailsWithResponse:(void(^)(AWSSNSGetEndpointAttributesResponse *response, AWSTask *))handleResponse {
NSString * deviceTokenForAWS = [self deviceTokenForAWS];
AWSSNS *manager = [AWSSNS SNSForKey:@"EUWest1SNS"];
AWSSNSGetEndpointAttributesInput *input = [AWSSNSGetEndpointAttributesInput new];
input.endpointArn = self.endpointArn;
AWSTask *getEndpointAttributesTask = [manager getEndpointAttributes:input];
[getEndpointAttributesTask continueWithBlock:^id(AWSTask *task) {
NSLog(@"%@ Error: %@", task.result, task.error);
AWSSNSGetEndpointAttributesResponse *result = task.result;
NSError *error = task.error;
if (error.code == AWSSNSErrorNotFound) {
[self createEndpointWithResponse:^(AWSSNSCreateEndpointResponse *createResponse) {
dispatch_async(dispatch_get_main_queue(), ^{
if (handleResponse != nil) {
handleResponse(result, task);
}
});
}];
} else {
NSLog(@"response for get endpoint attributes : %@", result);
NSString *token = [result.attributes valueForKey:@"Token"];
NSString *enabled = [result.attributes valueForKey:@"Enabled"];
NSLog(@"token : %@, enabled : %@", token, enabled);
BOOL wasSuccessful = [token isEqualToString:deviceTokenForAWS] && ([enabled localizedCaseInsensitiveCompare:@"true"] == NSOrderedSame);
if (!wasSuccessful) {
NSLog(@"device token does not match the AWS token OR it is disabled!");
NSLog(@"Need to update the endpoint");
AWSSNSSetEndpointAttributesInput *seai = [AWSSNSSetEndpointAttributesInput new];
seai.endpointArn = self.endpointArn;
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:deviceTokenForAWS, @"Token", @"true", @"Enabled", nil];
seai.attributes = attributes;
AWSTask *setEndpointAttributesTask = [manager setEndpointAttributes:seai];
[setEndpointAttributesTask continueWithBlock:^id(AWSTask *task) {
NSLog(@"response : %@, error: %@", task.result, task.error);
dispatch_async(dispatch_get_main_queue(), ^{
if (handleResponse != nil) {
handleResponse(result, task);
}
});
return nil;
}];
} else {
NSLog(@"all is good with the endpoint");
dispatch_async(dispatch_get_main_queue(), ^{
if (handleResponse != nil) {
handleResponse(result, task);
}
});
}
}
return nil;
}];
}