constructFCMPayload method

String constructFCMPayload({
  1. required User peer,
  2. required String message,
  3. required String token,
})

Implementation

String constructFCMPayload({
  required types.User peer,
  required String message,
  required String token,
}) {
  return jsonEncode({
    "to": token,
    'data': {
      'via': 'FlutterFire Cloud Messaging!!!',
      'count': 1,
      "userId": _user?.uid,
      "peerId": peer.id,
      "message": message,
      'title': getUserName(peer),
      'type': 'chat',
    },
    'android': {
      "notification": {
        "click_action": "FLUTTER_NOTIFICATION_CLICK",
      },
    },
    'notification': {
      'sound': "default",
      'click_action': "FLUTTER_NOTIFICATION_CLICK",
      'title': getUserName(peer),
      'body': message,
    },
  });
}