onMessage method

void onMessage(
  1. dynamic message
)

Handle push notification message

Implementation

void onMessage(message) {
  String pushId = message.data["push_id"] ?? "";
  String timestamp = message.data["time"] ?? "";
  String dataString = message.data["data"] ?? "";
  String channel = message.data["channel"] ?? "";

  Map<String, dynamic>? data;
  try {
    data = json.decode(dataString);
  } catch (_) {}

  _handlePush(pushId, timestamp, channel, data);
}