【问题标题】:AWS SNS Push Notifications not sendingAWS SNS 推送通知未发送
【发布时间】:2016-01-31 20:31:05
【问题描述】:

我为沙盒 iOS 设置了推送通知,它们曾经可以工作,但由于某种原因,目前无法正常工作。这是来自云观察日志的错误 AWS SNS:

{
"notification": {
    "messageMD5Sum": "39af77c36a92b71afb73212e74adf845",
    "messageId": "f8b4a21e-c3ba-52ed-8b17-ed36acf37e65",
    "timestamp": "2016-01-31 20:22:33.154"
},
"delivery": {
    "deliveryId": "a0941dde-8990-54ee-96e3-52f6e6d993d0",
    "destination": "arn:aws:sns:us-east-1:445291524102:endpoint/APNS_SANDBOX/BusyTime/a97020ec-4121-3995-a119-a7b6779ed602",
    "providerResponse": "NotificationErrorResponse(command=8, status=InvalidToken, id=1, cause=null)",
    "dwellTimeMs": 525,
    "attempts": 1,
    "token": "df6cb7064c391cc8ca1709c127b40f838768336c691512e00c73d01a18d6b0af",
    "statusCode": 8
},
"status": "FAILURE"
   }

这是我的发送代码(AWS Lambda 调用此代码):

params = {"Attributes": { //update the endpoint
                    "Enabled": 'true',
                },
                "EndpointArn" : user.endpointARN.S
        }
        sns.setEndpointAttributes(params, function(err, data) {
            if (err){ 
                console.log(err, err.stack); 
            }
            else{     

                var paramsSNS = {
                    TargetArn:user.endpointARN.S,
                    Message:message
                };

                sns.publish(paramsSNS, function(err, data) {
                if (err){ 
                    console.log(err, err.stack);
                }
                else{     
                    console.log(data);   
                    context.succeed(data);
                }
                });
            }       
        });

Lambda 方法的返回数据:

 {
  "ResponseMetadata": {
    "RequestId": "61f9bc48-fd8b-5408-b7a9-f36093c023ad"
  },
  "MessageId": "657eaace-69aa-5f87-96dd-e5e607e1d822"
}

我已将问题缩小到不与我的 lambda 方法关联,因为我尝试发布到直接从 SNS 控制台创建的端点。我也想知道为什么这个旧的实现在过去,一两个月前有效,而不再有效。我相信这可能与过时的证书有关,但我不确定如何检查/如果我的证书过时,我认为我不会收到这种提供者的回复。

【问题讨论】:

    标签: amazon-web-services apple-push-notifications amazon-sns aws-lambda


    【解决方案1】:

    错误表明令牌无效。除了标记“Enabled = true”之外,您可能还需要更新令牌。相关博文:http://mobile.awsblog.com/post/Tx223MJB0XKV9RU/Mobile-token-management-with-Amazon-SNS

    【讨论】:

    • 每次登录都会更新令牌。我还尝试通过手动插入令牌直接从 sns 控制台对其进行测试。
    • 您还有这个问题吗?您是否将更新的设备令牌传递给 sns.createPlatformEndpoint() 以便 SNS 知道它?
    猜你喜欢
    • 1970-01-01
    • 2015-09-28
    • 1970-01-01
    • 2019-07-10
    • 2016-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多