Warm tip: This article is reproduced from serverfault.com, please click

amazon web services-AWS Pinpoint:设置APNS“可变内容”:1

(amazon web services - AWS Pinpoint: Set APNS "mutable-content": 1)

发布于 2020-12-15 17:22:23

AWS Poinpoint APNS默认设置"mutable-content": 0

我正在使用Node.js。

以下工作正常,但mutable-content始终是0"mutable-content": 0

var messageRequest = {
'Addresses': {
https://forums.aws.amazon.com/: {
'ChannelType': channelType
}
},
'MessageConfiguration': {
'APNSMessage': {
'Action': action,
'Body': message,
'Priority': priority,
'SilentPush': silent,
'Title': title,
'TimeToLive': ttl,
'Url': url,
}
}

以下是payload使用上述设置发送APNS时获得的信息

["aps": {
alert = {
body = "TEST";
title = "Test message sent from Amazon Pinpoint.";
};
"content-available" = 1;
"mutable-content" = 0;
}, "data": {
pinpoint = {
deeplink = "https://www.example.com";
};
}]

如何"mutable-content": 1通过AWS Pinpoint设置APNS?

Questioner
user1107173
Viewed
0
alionthego 2021-04-14 20:35:18

没有文档,但是经过反复试验,这对我有用:

var payload = {
    "aps": {
        "alert": {
            "title": "Bold text in the notification",
            "body": "Second line in the notification"
        },
        "sound": "default",
        "mutable-content": 1
    }
};

var messageRequest = {
    Addresses: {
        [token]: {
            ChannelType: "APNS",
        },
    },
    MessageConfiguration: {
        APNSMessage: {
            RawContent: JSON.stringify(payload),
        },
    },
};

只需将它们的模板替换为RawContent并像通常那样创建有效负载即可。可以参考苹果文档,了解如何创建原始有效负载。你也可以使用此方法调整内容可用的键。这是如何使用json创建有效负载的链接:

https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification