MasterSA
MasterSA

Reputation: 3

Push Notification Configuration

we are currently implementing push notifications for iOS with IP Messaging from Twilio.

It works fine but Twilio sends only an "alert" in the payload to APNS.

As we understand we can only change the body of the payload in the default templates. ("Each of the Push Notification types have a default template for the payload (or notification body)")

How and where can we add the "sound" and "badge" to the payload?

Thank you so much!!! We can't find any examples and don't know how to implement it properly with "badge" and "sound"

Upvotes: 0

Views: 574

Answers (3)

philnash
philnash

Reputation: 73057

Twilio developer evangelist here.

I'm afraid you cannot currently set badges or sounds within the Twilio IP Messaging push notifications. However, due to feedback like this, I've been told the feature has been targeted for completion this quarter. So keep an eye out and you'll be able to do this soon!

Upvotes: 1

MasterSA
MasterSA

Reputation: 3

Twilio itself creates the payload. This is why I can't add the "Badge" and "sound". I don't understand where I can configure what Twilio sends to APNS except the "body" with the template following ...

A CURL example of configuring the NewMessage Push Notification type:

curl -X POST https://ip-messaging.twilio.com/v1/Services/{service sid} \ 
 -d 'Notifications.NewMessage.Enabled=true' \
 -d 'Notifications.NewMessage.Template=A New message in ${CHANNEL} from ${USER}: ${MESSAGE}' \
 -u '{twilio account sid}:{twilio auth token}'

The default template is: ${CHANNEL};${USER}: ${MESSAGE}

Upvotes: 0

Chris
Chris

Reputation: 247

When you create a payload for iOS push notifications you must specify the badge number and sound if it's your requirement, an example of a payload with a badge number and sound would look like this:

{
    "aps" : {
        "alert" : {
            "title" : "Notification Test",
            "body" : "This is a push notification"
        },
        "sound" : "default",
        "badge" : 1
    },
}

I'm not entirely sure what the templates look like for Twilio but essentially all payloads for iOS are in the same format as above.

It's worth noting that I have formatted the payload so it is easier to read but ideally you would want to remove any whitespace from the example above.

Upvotes: 0

Related Questions