FCM onMessageReceived() never called - android

I know there is 2 kind of payload, notification and data. Currently, I am using data payload as I want to create custom notification and register FirebaseMessagingService in Manifest.
My expected behavior is that whenever I send push onMessageReceived() method should be called whether app is in the foreground, background or killed.
The issue currently I am facing that onMessageReceived() does not invoke for some devices when I killed app but not with all devices.
The issue is with OnePlus 5 and Lenevo.
I have also checked others app in my phone which uses Firebase for push and their custom push notification comes when app is killed.
1. Is this issue with Firebase?
2. Is there any solution?

Related

Display default notification in onMessageReceived

I'm using Firebase Cloud Messaging for Android. When my app is in the foreground, FCM will invoke onMessageReceived on my app's FirebaseMessagingService subclass.
When my app is in the background, the Android OS will create a default notification entry in the system tray. That notification entry looks pretty good to me; for the notifications I need to send, I don't particularly need to interrupt the user with the notification. The default notification in the system tray is just fine.
My question is, how do I make that "default" notification happen in onMessageReceived when my app is in the foreground? Is there a way to say, "I don't need to intercept this notification; please just do what you'd normally do if I were in the background"?
(Do I have to simulate it by hand with NotificationCompat.Builder? If so, which settings do I need to pass to get default behavior?)
When the app is in the background, your notifications are processed by the Google Services, which takes care of displaying your notifications as required, including the default click action (opening the app) and the notification icon.
When the app is in the foreground, the received messages are processed by the app.
Yes, you will have to mimic the NotificationCompat.Builder to look like default. There is no other way to do this without intercepting with onMessageReceived() callback.
Reference: https://firebase.google.com/docs/cloud-messaging/android/receive

How to get notification on firebase chat app using local notification?

How to get notification when the app is at the backgroenter code hereund or forced stopped?
I want to get a notification in the Android app using a broadcast receiver, Problem is that I have found solution when the app is opened. when app is opened I am able to receive notification. But when the app is killed or forced stopped I am not getting the notification. I want to know that how can i get notification when app is connected to the internet and get an notification even app is forced stopped.
There are two types of messages in FCM (Firebase Cloud Messaging):
Display Messages: These messages trigger the onMessageReceived() callback only when your app is in foreground
Data Messages: Theses messages trigger the onMessageReceived() callback even if your app is in foreground/background/killed
Firebase team have not developed a UI to send data-messages to your devices, yet.
When your app is closed the notification submitted to your system, and can you retrieve the data in notification when you click on notification your application is started and in your launcher activity can you get the data intent

How can trigger onNotification when app in background React Native Firebase

I am investigating about React Native and Firebase Cloud Messaging. In the document, I see that has 2 types of message can be send to client is:
Notification message ( Or Notification and data message )
Data - only message
The first one can be trigger by client using onNotification, and it only trigger if the app on foreground, if in background no way to trigger that has a notification. Just onNotificationOpened can be fired.
The second is inverse, the app can trigger on foreground and background. In case the app has been closed/swiped, on Android luckily it can be triggered also by using a Handler background. But on iOS if the app closed/swiped that no way until we open app again.
The problem is what type of 2 message above that I can use to listen the notification coming, and how it can work if app in foreground, background and closed.
Hope someone can help me about this.

Fire-base push notification starts the app when message received even whiteout clicking the message

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?
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.

Firebase Messaging Android Notification not received when app is open

I configured my Android app as the Firebase docs and I am receiving notifications normally, however when the app is in the foreground I do not get any notifications. Is there a way to get the notifications even if the app is in the foreground.
if you have done all the steps as given in the docs then when your app is in foreground your "sendNotification()" is not called, which is responsible for showing the notification. If you want notification when app is in foreground then just sendNotification() inside the onMessageReceived()
for more check this link
https://github.com/firebase/quickstart-android/blob/master/messaging/app/src/main/java/com/google/firebase/quickstart/fcm/MyFirebaseMessagingService.java

Categories

Resources