您好我正在尝试发送这样的推送通知
message3 = {"APNS_SANDBOX":"{\"aps\": {\"alert\": \"some alert\",\"sound\": \"default\",\"badge\": 1},\"message\": \"additional information\",\"id\": 1234}"}
response = client.publish(
#TopicArn='string',
TargetArn = someEndpoint,
Message = json.dumps(message3),
MessageStructure= 'json'
#Subject='string',
)
一切正常。但我需要警报变量。如果我尝试在message3 json对象中放置一个自定义文本变量,我会不断收到此错误:
"errorType": "ClientError",
"errorMessage": "An error occurred (InvalidParameter) when calling the Publish operation: Invalid parameter: Message Reason: Invalid notification for protocol APNS_SANDBOX: Notification is malformed"
有人可以帮忙吗?谢谢!!
答案 0 :(得分:2)
这似乎是这样的。
test = "test"
message = {'aps': {'alert': test, 'sound': 'default','badge': 1},'message': 'additional information','id': 1234}
dumped = json.dumps(message)
message3 = {"APNS_SANDBOX":dumped}
response = client.publish(
#TopicArn='string',
TargetArn = someEndpoint,
Message = json.dumps(message3),
MessageStructure= 'json'
#Subject='string',
)
这就是你的意思,@ kichik?非常感谢!