我正在使用亚马逊 SNS。通知正常工作,但有时会出现以下错误:
{
"message": "Endpoint is disabled",
"code": "EndpointDisabled",
"name": "EndpointDisabled",
"statusCode": 400,
"retryable": false
}
或许你知道原因。
我正在使用亚马逊 SNS。通知正常工作,但有时会出现以下错误:
{
"message": "Endpoint is disabled",
"code": "EndpointDisabled",
"name": "EndpointDisabled",
"statusCode": 400,
"retryable": false
}
或许你知道原因。
push-notification-failures
的新SNS主题,然后将您的APNS / APNS_SANDBOX应用程序的“投递失败”事件与其关联。通过电子邮件订阅此事件(并确认),您将获得有关故障的有用调试信息。所有这些都可以通过SNS控制台完成,不需要进行API调用。FailureMessage
表示您正在从APNS_SANDBOX发送消息到已注册的APNS设备或反之亦然。这可能意味着您的构建系统的APNS设置错误。(我们存在一些令人沮丧的问题,即使用APNS_SANDBOX来构建开发人员二进制文件而使用APNS进行本地测试和QA的TestFlight构建二进制文件,这就是我走上这条路的原因。)目前我已经找到了3个原因:
这些问题涉及到Iphone / Ipad。
您向终端点推送消息,但令牌无效/已过期。令牌会在以下情况下变为无效:
它属于一个已经卸载了的应用。
如果设备已从备份中恢复,则会使令牌无效,此时您的应用应请求新令牌并相应地更新 SNS 终端点令牌。
已重新在同一设备上安装应用。对于 Android 设备,应用将被分配一个新令牌。这种情况也会发生在 APNs 上,但在 Android 上更为常见。
如果在 xCode 中选择了错误的配置文件,则 APNs 会失败,并且设备稍后会被禁用。
如果错误地将 IOS 开发的令牌用于 IOS 生产应用程序或反之亦然。
如果 Apple 因任何原因无效您的 IOS 推送证书或某人从 itunes connect 门户撤销了推送证书,则需要几个小时才能使设备停用。
如果您在 Google 开发人员控制台中更新了 API 密钥,但没有相应地更新 SNS 平台应用程序凭据,则同样适用于 GCM。
您向 APNs 设备终端点推送消息,但由于过期的推送证书而禁用了应用程序。
您向 GCM 设备终端点推送消息,但未相应地更新 SNS 平台应用程序凭据中的 API 密钥。
有关详细信息,我建议阅读这篇优秀的文章,它解决了我的问题。
我有同样的问题。
这是我所做的:
export the PRIVATE KEY from Keychange Access to a *private.p12 file
use openssl with the downloaded .cer file (from iOS Developer MemberCenter) to create a public .pem certificate
use openssl with the generated *private.p12 file to create a private .pem keyfile
Choose the FULL CERTIFICATE from Keychain Access with a .p12 extension, and type in the passphrase you chose when exporting from Keychain Access Copy the content of the public CERTIFICATE .pem file, to the textarea labelled "Certificate", including the starting and ending lines:
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
Copy only the part of the private key .pem file starting and ending with the following lines, to the textarea labelled "Private Key":
-----BEGIN RSA PRIVATE KEY-----
-----END RSA PRIVATE KEY-----
*//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*
objDictCheckEndpointEnable.Add("Enabled", "True");
- Nicholas Petersen.Add("Enabled", "True");
。顺便提一下,昨天在处理这个问题时我注意到AWS将值小写化,即"true"或"false",但这可能并不重要。 - Nicholas Petersen - (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;
}];
}