Messaging doesn't emit onMessage when App is in background and comes to forground
isipisi89 opened this issue · 2 comments
Hello i found one more bug in the messaging SDK.
I think this is a library issue but i dont know where to post it. So lets try here.
So on android when i start the app from a notification the onMessage function is emited fine.
When the app is running the onMessage function is emited fine too.
But when the app is in the background and i tap on a notification, the app comes to forground, but dosent emits the onMessage function. There is nothing happening.
Is this mybe a bug in the messaging library?
Sorry for the trouble. There's an extra step that isn't well documented right now in messaging. I'm working on getting the docs updated.
When you start the app from a notification the notification isn't communicated to your app the same way it is when the app is already running. It's instead passed to your activity's onNewIntent and must be routed to FCM so that it can send the onMessage callback.
The way to fix this is to use the MessageForwardingService. Take a look at this example
Intent message = new Intent(this, MessageForwardingService.class);
message.setAction(MessageForwardingService.ACTION_REMOTE_INTENT);
message.putExtras(intent);
startService(message);
If you're using your own custom activity, you'll need to add that code to you onNewIntent. If you're using something like NativeActivity to launch your C++ app, you'll need to extend it and override onNewIntent.
Hope this helps. Let me know if you have any trouble getting this to work.
Okey thx this solved the problem.
Alsow importet is to set the services in the xml file.
Regards isy