class FcmPayload {
  FcmPayload({
    this.title,
    this.body,
    this.data,
  });

  factory FcmPayload.fromMessage(Map<String, dynamic> message) {
    final notification = message['notification'] as Map<String, dynamic>?;
    final rawData = message['data'];

    return FcmPayload(
      title: notification?['title']?.toString(),
      body: notification?['body']?.toString(),
      data: rawData is Map ? Map<String, dynamic>.from(rawData) : null,
    );
  }

  final String? title;
  final String? body;
  final Map<String, dynamic>? data;
}
