The background handler is called, everything works fine but I don't know how to get a BuildContext instance for navigating to a new screen. I have this handler
Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {
var notificationData = message.data;
var view = notificationData['view'];
if(view == 'MessagesScreen') {
Map<String, dynamic> videoData = json.decode(
notificationData['video_data']);
VideoItem videoItem = VideoItem.fromJson(videoData);
Navigator.pushNamed(context, '/playerScreen', arguments:{videoItem});
} else {
view = '/$view';
Navigator.pushNamed(context, view);
}
return Future<void>.value();
}
It's called like this
await Firebase.initializeApp();
FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler);
I'm using Firebase messaging : 9.1.2
Any idea how to achieve this ?
Thx