Skip to content

Call FirebaseMessagingService#onMessageReceived, the app in the background. #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
najeira opened this issue Sep 25, 2018 · 10 comments
Closed

Comments

@najeira
Copy link

najeira commented Sep 25, 2018

What feature would you like to see?

Call FirebaseMessagingService#onMessageReceived, the app in the background.

@morepork
Copy link

Hi, just to clarify, do you mean that for notification messages to call onMessageReceived() at the same time as the notification is shown, or once the user taps on and opens the notification, or something else?

@najeira
Copy link
Author

najeira commented Sep 26, 2018

before notification.

I would like to customize notifications using NotificationCompat.BigPictureStyle and NotificationCompat.BigTextStyle.

@samtstern
Copy link
Contributor

@najeira I think what you want to do is send a data message rather than a notification message, which will give you full control over the UI you display.

@najeira
Copy link
Author

najeira commented Sep 27, 2018

@samtstern Thanks for your reply.

I think that using data message to show notifications is bad workaround. On the server side, it is cumbersome to do different processing for iOS and Android. For example, with topic delivery, iOS and Android can not be separated.

Is there any reason to not provide a means to customize the notifications in the background?

@julien1619
Copy link

Same request here! In our usecase we want to be able to update the badge displayed by some launchers, but, as we are not called when the app is in background, we have to use only the data payload, encapsulate the whole notification data in it, use the iOS custom keys to keep it working like before on iOS, and finally handle the notification display on Android manually.

I can't see any technical reason to not call onMessageReceived() everytime, even in background.

@samtstern
Copy link
Contributor

Is there any reason to not provide a means to customize the notifications in the background?

This is a technical restriction that's outside the scope of the Android SDK. It's really an OS-level decision. Remember, the FCM message is received by the Google Play services process and your process is not always notified.

I am going to close this issue as there's nothing that can be done in this repo to fix it. However I will forward on your feedback to the FCM team in case they decided to revisit their decisions on background processing in the future.

@najeira
Copy link
Author

najeira commented Dec 18, 2018

This is a technical restriction that's outside the scope of the Android SDK. It's really an OS-level decision.

I can not agree with this.

Android OS allows us to customize notifications even if apps is in background.

It is decision of SDK not to call onMessageReceived, It's written in FirebaseMessagingService#handleIntent.

Instead, please, please remove final from FirebaseMessagingService#handleIntent.

Without this, I can not move from GCM to FCM. I am in serious trouble.

@najeira
Copy link
Author

najeira commented Dec 18, 2018

It is rare to receive notification when an application is in the foreground. For example, Gmail also displays special notifications. Why are not we allowed?

Should I use GCM instead of FCM?

@kroikie
Copy link
Contributor

kroikie commented Dec 18, 2018

Hi @najeira and @julien1619 thanks for this feature request. @samtstern is correct that this is a change that has to be made in Google Play Services which currently does not pass display notifications onto the SDK before being displayed. This is something the FCM team is looking into, we would like to have as unified an experience on Android and iOS as possible.

@najeira you mentioned '''For example, with topic delivery, iOS and Android can not be separated.'''. You can use the V1 HTTP API to clearly define different notification message payloads. Also GCM does not provide any different functionality here it will be deprecated soon, FCM should be used.

@najeira
Copy link
Author

najeira commented Dec 19, 2018

@kroikie Thanks for your reply.

I will try to use V1 HTTP API .

Can we implement custom notifications like Gmail?

@firebase firebase locked and limited conversation to collaborators Oct 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants