I want to be able to handle iOS and Android notifications using Firebase Messaging.
I followed a tutorial in which the person received notification payloads in this format on Android:
notification:{ title: "title" , body: "body" } }
However on iOS I am receiving a payload in this format:
aps:{ alert:{ title: "title" , body: "body" } }
What is the best way to handle this within Flutter when configuring firebase messaging like below?
_firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) async {
showDialog(
context: context,
builder: (context) => AlertDialog(
content: ListTile(
title: Text(message['aps']['alert']['title']),
subtitle: Text(message['aps']['alert']['body']),
),
actions: <Widget>[
FlatButton(
child: Text("Dismiss"),
onPressed: () => Navigator.of(context).pop(),
)
],
),
);
},
Are these payloads customizable or should I be doing something like:
if (Platform.isIOS) {
...Text(message['aps']['alert']['title']),
} else {
...Text(message['notification']['title']),
}