You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are having a problem when Flutter Fire Messaging is receiving a background notification. We have setup a top level Callback Handler that is called when a background notification is received:
static Future<void> backgroundMessageHandler(RemoteMessage message) async { // initialize widgets binding for plugins WidgetsFlutterBinding.ensureInitialized(); final SendPort messagesPort = IsolateNameServer.lookupPortByName(BACKGROUND_MESSAGES_PORT_NAME); messagesPort?.send(message); }
As can be seen, this handler is designed to send a message to a SendPort that has been setup in main method. When we launch our app, then move it to the background everything works perfectly.
However, if we restart the phone (so that the app is not running) and then send a notification, we can see from LOGCAT that
But it seems that messagesPort? is null. I assumed that when aa message handler is called from the background, that the main method is run; is this correct?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
We are having a problem when Flutter Fire Messaging is receiving a background notification. We have setup a top level Callback Handler that is called when a background notification is received:
static Future<void> backgroundMessageHandler(RemoteMessage message) async { // initialize widgets binding for plugins WidgetsFlutterBinding.ensureInitialized(); final SendPort messagesPort = IsolateNameServer.lookupPortByName(BACKGROUND_MESSAGES_PORT_NAME); messagesPort?.send(message); }
As can be seen, this handler is designed to send a message to a SendPort that has been setup in
main
method. When we launch our app, then move it to the background everything works perfectly.However, if we restart the phone (so that the app is not running) and then send a notification, we can see from LOGCAT that
I/FLTFireMsgService: FlutterFirebaseMessagingBackgroundService started!
But it seems that messagesPort? is null. I assumed that when aa message handler is called from the background, that the main method is run; is this correct?
Beta Was this translation helpful? Give feedback.
All reactions