Search code examples
amazon-web-servicesapple-push-notificationsaws-pinpoint

AWS Pinpoint: Set APNS "mutable-content": 1


AWS Poinpoint APNS by default sets "mutable-content": 0.

I am using Node.js.

Below works fine, but mutable-content is always 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,
}
}

Below is the payload I get when an APNS is sent using the above setup

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

How can I set "mutable-content": 1 for an APNS through AWS Pinpoint?


Solution

  • There is no documentation but this worked for me after some trial and error:

    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),
            },
        },
    };
    

    Just replace their template with RawContent and create the payload as you would normally. Can refer to apple docs on how to create the raw payload. You can also adjust content-available key using this method. Here is the link to how to create a payload with json:

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