What is best practice for state management while receiving push notifications to update ui?

29 Views Asked by At

I am receiving some push notifications from firebase cloud messaging, either foreground or background mode. I save the data from push notification data and want to update UI. However in background mode, there is no context, so I can not use provider. For foreground mode, i declare this method in a method that can not access context:

 FirebaseMessaging.onMessage.listen((RemoteMessage message) async {
  await _signaturePushNotificationHandleService.handle(message);
}); 

So, I can not use provider, too.

I tried writing foreground handler in stateful widget but i use foreground handler in multiple stateful widget. I tried streambuilder for background, but while app is closed, i receive some data but when app is opened, another stream is initialized.

0

There are 0 best solutions below