Send Push over OMNI API
The OMNI API enables automatic fallback to another channel according to the defined order.
To send push with OMNI API you need to:
- Create an OMNI scenario
- Send a message with OMNI scenario
- Get delivery reports (optional)
Create OMNI Scenario
To create an OMNI scenario, you need to define the OMNI steps which will be sequentially executed.
To send push notifications with the scenario, you should use push (“channel”: “PUSH”) and APPLICATION CODE as the sender (“from”: “APPLICATION CODE”) generated during the setup of the mobile application.
Find more information on how to create the OMNI scenario in the Create Mobile Application Profile article in the Documentation Hub. Refer to the Infobip API Developer Hub for more information on how to create an OMNI scenario.
Most common OMNI scenario is push with SMS as a fallback channel. The following code snippet demonstrates how to create such a scenario.
{
"name" : "push + SMS scenario",
"flow": [
{
"from": "APPLICATION CODE",
"channel": "PUSH"
},
{
"from": "YOUR_REGISTERED_SMS_SENDER",
"channel": "SMS"
}
],
"default": true
}
Send Messages With OMNI Scenario
Once you've created the OMNI scenario (identified by the key
parameter), you can send your OMNI messages through defined communication channels.
NOTE
To be able to send push messages using Infobip web interface, you need to have at least one mobile application profile registered on the platform. Refer to the Create Mobile Application Profile for detailed instructions.
If you need to send the same message to every channel in the OMNI scenario, you can use the simple OMNI message method. If you want to send different messages to different channels, you need to use the advanced OMNI message method.
You can use different options for how push notification is processed when it is received.
Name |
Required |
Default value |
Type |
Description |
---|---|---|---|---|
vibrationEnabled |
No |
true |
boolean |
Notification vibration (Android only). |
soundEnabled |
No |
true |
boolean |
The sound when notification arrives on a device. |
soundName |
No |
- |
string |
The name of the custom sound played when a notification arrives on a device. The file should be in the app; max 30 seconds long. The file extension is required for iOS and optional for Android. For custom sound to be played |
badge |
No |
|
integer |
Badge counter (iOS only). |
contentUrl |
No |
|
string |
URL of the image displayed in the notification. Rich push notifications are available on devices with iOS 10 and Android 4.1.+. Supported on iOS since MM SDK version 2.5.8. Supported on Android since MM SDK version 1.6.4. |
category |
No |
|
string |
Category id for actionable notification. Supported on Android since MM SDK version 1.6.16. Supported on iOS since MM SDK version 2.6.9. Predefined category ids: mm_accept_decline - Accept & Decline button actions. |
inAppStyle |
No |
|
string |
Possible values: |
isSilent |
No |
|
boolean |
Set to |
title |
No |
Application name set within mobile project |
string |
Notification title displayed within notification. Requires iOS 10+ or Android 4.1+ (may depend on Android custom firmware) |
The code snippet demonstrates how to send a push notification with options with OMNI API.
{
"scenarioKey": "key",
"destinations": [
{
"to": {
"phoneNumber": "phone number"
}
}
],
"push": {
"text": "This PUSH message will pop up on your mobile device.",
"customPayload": {
"contentUrl": "https://someurl.com/content",
"deepLink": "myApp://some/link"
},
"notificationOptions": {
"vibrationEnabled": true,
"soundEnabled": true,
"soundName": "sound.wav",
"badge": 1,
"contentUrl": "http://www.mydomain.com/images/image1.jpg",
"category": "mm_accept_decline",
"inAppStyle": "MODAL",
"title": "This is some title"
},
"targetOnlyPrimaryDevices": true
},
"sms": {
"text": "This is the SMS failover message"
}
}
Get Delivery Report
You can check the status of messages sent and get delivery reports with the OMNI reports method.