createPush method

Future<Message> createPush({
  1. required String messageId,
  2. required String title,
  3. required String body,
  4. List<String>? topics,
  5. List<String>? users,
  6. List<String>? targets,
  7. Map? data,
  8. String? action,
  9. String? image,
  10. String? icon,
  11. String? sound,
  12. String? color,
  13. String? tag,
  14. String? badge,
  15. bool? draft,
  16. String? scheduledAt,
})

Create push notification

Create a new push notification.

Implementation

Future<models.Message> createPush(
    {required String messageId,
    required String title,
    required String body,
    List<String>? topics,
    List<String>? users,
    List<String>? targets,
    Map? data,
    String? action,
    String? image,
    String? icon,
    String? sound,
    String? color,
    String? tag,
    String? badge,
    bool? draft,
    String? scheduledAt}) async {
  final String apiPath = '/messaging/messages/push';

  final Map<String, dynamic> apiParams = {
    'messageId': messageId,
    'title': title,
    'body': body,
    'topics': topics,
    'users': users,
    'targets': targets,
    'data': data,
    'action': action,
    'image': image,
    'icon': icon,
    'sound': sound,
    'color': color,
    'tag': tag,
    'badge': badge,
    'draft': draft,
    'scheduledAt': scheduledAt,
  };

  final Map<String, String> apiHeaders = {
    'content-type': 'application/json',
  };

  final res = await client.call(HttpMethod.post,
      path: apiPath, params: apiParams, headers: apiHeaders);

  return models.Message.fromMap(res.data);
}