setNotificationFormat method
- 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}" } } }
A special server-managed argument may also be used:
${LS_MPN_subscription_ID}
: the ID of the MPN subscription generating the push notification.
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.
-
format
the JSON structure to be used as the format of push notifications. -
See ApnsMpnBuilder
Implementation
Future<void> setNotificationFormat(String format) async {
_notificationFormat = format;
if (_remoteActive) {
var arguments = <String, dynamic> {
'notificationFormat': format
};
return await _invokeMethod('setNotificationFormat', arguments);
}
}