I am trying to implement notifications for my app, but when initializing notifications FirebaseMessaging.onBackgroundMessage(notificationHandler)
gives error
Error:
E/flutter (28265): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: Null check operator used on a null value E/flutter (28265): #0 MethodChannelFirebaseMessaging.registerBackgroundMessageHandler (package:firebase_messaging_platform_interface/src/method_channel/method_channel_messaging.dart:173:53) E/flutter (28265): #1 FirebaseMessagingPlatform.onBackgroundMessage= (package:firebase_messaging_platform_interface/src/platform_interface/platform_interface_messaging.dart:108:16) E/flutter (28265): #2 FirebaseMessaging.onBackgroundMessage (package:firebase_messaging/src/messaging.dart:100:31)
notificationHandler:
Future<void> notificationHandler(RemoteMessage message) async {
/// do sth with data
}
Note: FirebaseMessaging.onMessage
and FirebaseMessaging.onMessageOpenedApp
works without error