Firebase Push notification for Android App, starts the app when received the message while App is not running (killed), even without clicking at the notification. Does any one knows if this is the default Android behavior or there is some settings I need to change?
Asked
Active
Viewed 112 times
0
-
That depends on the type of message you send. Notification-only messages will be handled by the system if the app is not active. But data messages will always be delivered to your app's `onMessageReceived` handler. – Frank van Puffelen Mar 06 '18 at 15:46
-
@FrankvanPuffelen, even if I don't add any data (Notification only), it will start my app, is that default behavior? – user8605601 Mar 06 '18 at 16:01
-
I'm not sure. It really depends on what "start my app" means. What do you send, and what code in your app do you see being triggered? – Frank van Puffelen Mar 06 '18 at 17:09
-
@FrankvanPuffelen, by "start my app" I mean when the app is Neither on Background nor Foreground, when the notification received, it will open up the app (start), without clicking on notification, but when the app is either on Background or Foreground nothing happens until you touch (click) the notification. – user8605601 Mar 06 '18 at 17:16
1 Answers
1
I'm still not clear on what you mean by open up the app (start).
Here is what I see when a notification-only message is sent to an app that is not in memory (version 11.8.0):
- An instance of the app is created. This occurs even when the app does not define a service that extends FirebaseMessagingService.
- If the app does define a
FirebaseMessagingService
, the service is created and destroyed.onMessageReceived()
is not called. - In both cases, all processing occurs in the background; no activity is started until the user taps on the notification.
- These observations are based on log messages output from my messaging service and Application instance.
While the descriptions in the documentation, such as FCM automatically displays the message to end-user devices on behalf of the client app, correctly indicate that the handling of the message is done "by the system", they don't mention that creation of an app instance is a side effect of that processing.

Bob Snyder
- 37,759
- 6
- 111
- 158
-
I extended FireBaseMessagingService, and onMessageReceived gets called every time, I think that's the purpose. by Open up the app (start) I mean when the app is Not active, it opens the app WITHOUT tapping – user8605601 Mar 06 '18 at 22:07
-
Can you update your post to include the message you are sending. For a non-foreground app, `onMessageReceived()` should only be called if there are data fields. – Bob Snyder Mar 06 '18 at 22:46