Amazon web services 获得;“已禁用”;来自亚马逊社交网站

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指示端点无效时,

我正在使用亚马逊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将警告您证书不匹配,但它不会对开发端点进行此类检查。只有当您得到平台令牌错误时,您才能知道端点被阻塞

我当然希望这能帮助其他人,因为这会让我分心。

我也有同样的问题。 这就是我所做的:

  • 将完整证书从Keychain Access导出到.p12文件
  • 将私钥从Keychange Access导出到*PRIVATE.p12文件

  • 将openssl与下载的.cer文件(来自iOS Developer MemberCenter)一起使用,以创建公共.pem证书

  • 将openssl与生成的*private.p12文件一起使用,以创建private.pem密钥文件

  • 在AWS SNS中创建一个新的应用程序。给它起个名字。选择Apple Development
  • 从Keychain Access中选择扩展名为.p12的完整证书,并键入从Keychain Access导出时选择的密码短语 将public CERTIFICATE.pem文件的内容复制到标记为“CERTIFICATE”的文本区域,包括起始行和结束行:

    -----BEGIN CERTIFICATE-----
    -----END CERTIFICATE-----
    
  • 仅将private key.pem文件中以以下行开头和结尾的部分复制到标记为“private key”的文本区域:

  • 我将Cordova与phonegap插件push 1.4.4一起使用,但我的问题与phonecap无关。除了对上面的内容有点困惑之外,我最后的诀窍是在XCode中打开我的项目,找到我项目的目标,然后启用推送通知。这会自动将“推送通知”权限添加到应用程序ID。。下次在您的设备上安装应用程序时,推送通知应该会起作用。至少对我来说是这样


    我希望这能帮那些遇到与我相同问题的人节省1/2天的工作时间!:)

    采取严厉措施前的快速检查表:

  • 使用钥匙链应用程序生成证书签名请求(CSR)
  • 使用钥匙链应用程序将APNS证书及其私钥导出到单个p12文件中
  • 在Amazon SNS中创建新应用程序时,平台必须与APNS环境相匹配(开发/生产
  • 当您请求设备令牌时,您必须位于正确的应用程序中(应用程序的包标识符与APNS证书匹配)
  • 在AWS SNS中创建新的平台端点时,必须将设备令牌添加到正确的应用程序(良好的应用程序证书和良好的开发/生产平台)

  • 在我的例子中,我使用第三方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;
        }];
    }