setNotificationFormat method

void setNotificationFormat(
  1. String format
)

Sets the JSON structure to be used as the format of push notifications.

This JSON structure is sent by the server to the push notification service provider (i.e. Google's FCM), hence it must follow its specifications.
The JSON structure may contain named arguments with the format ${field}, or indexed arguments with the format $[1]. These arguments are replaced by the server with the value of corresponding subscription fields before the push notification is sent.
For instance, if the subscription contains fields "stock_name" and "last_price", the notification format could be something like this:

  • { "android" : { "notification" : { "body" : "Stock ${stock_name} is now valued ${last_price}" } } }
Named arguments are available if the Metadata Adapter is a subclass of LiteralBasedProvider or provides equivalent functionality, otherwise only indexed arguments may be used. In both cases common metadata rules apply: field names and indexes are checked against the Metadata Adapter, hence they must be consistent with the schema and group specified.
A special server-managed argument may also be used:
  • ${LS_MPN_subscription_ID}: the ID of the MPN subscription generating the push notification.
The MpnBuilder object provides methods to build an appropriate JSON structure from its defining fields.
Note: if the MpnSubscription has been created by the client, such as when obtained through [LightstreamerClient.getMpnSubscriptions], named arguments are always mapped to its corresponding indexed argument, even if originally the notification format used a named argument.
Note: the content of this property may be subject to length restrictions (See the "General Concepts" document for more information).

Lifecycle This property can be changed at any time.

Notification A change to this setting will be notified through a call to MpnSubscriptionListener.onPropertyChanged with argument notification_format on any MpnSubscriptionListener listening to the related MpnSubscription.

Implementation

external void setNotificationFormat(String format);