My issue seems similar to this firebase_messaging onResume and onLaunch not working however I don't think the solution work for me since I'm already trying to access the fields in data property.
I'm currently displaying a push notification to users when the app is running and that part is working fine. However I also want to show a notification when the app is in the background and when the user clicks on it, they should be greeted with an alert message.
In the onResume method if I do this, it works and when I open the notification I see the message printed on the console and also the Alert message
onResume: (Map<String, dynamic> message) async {
print("onResume: $message");
Alert(context: context, title: 'Hi User!').show();
}
However, if I try to access the data property in the title, I do see the message printed on the console but I don't see any Alert now
onResume: (Map<String, dynamic> message) async {
print("onResume: $message");
Alert(context: context, title: message['data']['user']['name']).show();
}
The same piece of code works when the app is running in the onMessage
property however for both onLaunch
and onResume
I see the above described behavior. Below are the logs from the console
W/awesome_projec(13005): Accessing hidden method Landroid/os/WorkSource;->add(I)Z (light greylist, reflection)
W/awesome_projec(13005): Accessing hidden method Landroid/os/WorkSource;->add(ILjava/lang/String;)Z (light greylist, reflection)
W/awesome_projec(13005): Accessing hidden method Landroid/os/WorkSource;->size()I (light greylist, reflection)
W/awesome_projec(13005): Accessing hidden method Landroid/os/WorkSource;->get(I)I (light greylist, reflection)
W/awesome_projec(13005): Accessing hidden method Landroid/os/WorkSource;->getName(I)Ljava/lang/String; (light greylist, reflection)
E/FlutterFcmService(13005): Fatal: failed to find callback
W/FirebaseMessaging(13005): Missing Default Notification Channel metadata in AndroidManifest. Default value will be used.
E/FlutterFcmService(13005): Fatal: failed to find callback
I/flutter (13005): onResume: {notification: {}, data: {collapse_key: com.example.awesome_project, google.original_priority: high, google.sent_time: 15751462256, google.delivered_priority: high, google.ttl: 2419200, from: 554610817622, location: {"latitude":24.6351,"longitude":70.2764}, user: {"phoneNumber":"1274545332","name":"Bobby94"}, google.message_id: 0:157514622564xxx}}