-
Notifications
You must be signed in to change notification settings - Fork 16
Custom message payload
Tereza Juric edited this page Aug 8, 2017
·
22 revisions
By using Custom Payload you can send custom data together with regular push messages from New Campaign page on Customer portal. The custom payload can be made of key-value pairs:

or plain JSON:

It is also possible to send Custom Payload using Single PUSH message and Multiple PUSH messages APIs.
The following example code shows how you can retrieve the custom payload bundle from within your application by subscribing to message received Event:
// declare message receiver
private final BroadcastReceiver messageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Message message = Message.createFrom(intent.getExtras());
// extract your custom data
JSONObject customPayload = message.getCustomPayload();
if (customPayload != null) {
final String uri = customPayload.optString("uri", "");
final String dish = customPayload.optString("dish", "");
Log.d("CustomPayload", String.format("dish is: %s, uri is: %s", uri, dish));
}
}
}
@Override
protected void onResume() {
super.onResume();
// subscribe to MESSAGE_RECEIVED event
LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(this);
localBroadcastManager.registerReceiver(messageReceiver, new IntentFilter(Event.MESSAGE_RECEIVED.getKey()));
}
If you have any questions or suggestions, feel free to send an email to [email protected] or create an issue.
- Library events
- Server errors
- Users and installations
- Messages and notifications management
- Inbox
Geofencing API- DEPRECATED- Android Manifest components
- Privacy settings
- In-app chat
- Infobip RTC calls and UI
- Backup rules