I implemented firebase cloud messaging and followed the following tutorial https://www.youtube.com/watch?time_continue=304&v=2TSm2YGBT1s&feature=emb_logo. And I got it working for the most part. Whenever the app is in the background or closed I get a notification and it will open the app and execute the callback onResume or onLaunch.
But I can't seem to get the onMessage callback to work. Whenever the app is in the foreground and I send the notification, the onMessage isn't called? I get the following log to my console
E/FlutterFcmService(18141): Fatal: failed to find callback
W/FirebaseMessaging(18141): Unable to log event: analytics library is missing
W/FirebaseMessaging(18141): Unable to log event: analytics library is missing
I have not seen onBackgroundMessage being called either.
Notification Service
class CloudMessagingService extends NotificationService
{
final FirebaseMessaging firebaseMessaging = FirebaseMessaging();
CloudMessagingService()
{
if(Platform.isIOS)
firebaseMessaging.requestNotificationPermissions(IosNotificationSettings());
firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) async {
print('I have a cloud messaging message yay');
print('onMessage: $message');
},
onBackgroundMessage: (Map<String, dynamic> message) async {
print('onBackgroundMessage: $message');
},
onLaunch: (Map<String, dynamic> message) async {
print('onLaunch: $message');
},
onResume: (Map<String, dynamic> message) async {
print('onResume: $message');
},
);
}
Future<void> sendNotificationToGroup(GroupModel group, NotificationType type)
{
print('Send ${type.valueString} notification to ${group.id}');
return null;
}
}
I am testing this on a android emulator with the Pixel 3XL