Android - firebase notifications behaviour - android

As far as I understand regarding Firebase push notifications:
When the user taps on a notification while the app is closed the notification data arrives to the launch screen.
If the app is in foreground, the notification is fetched in the onMessageReceived method from the service that overrides FirebaseMessagingService
But... what I need to detect is...
When a notification has been received but the user didn't enter into the app tapping on it but clicking on the app icon.
I need to display a countdown popup when the notification is received, but in that case (clicking on the icon) I have no information about the received notification.

Related

Get all notifications that are currently displayed by the app

I have an app that receives notifications with data in them. I can retreive that data fine when the notification is tapped or when the app is active and the notification is received, but it doesn't work when I open the app with an active notification. Is there some way to see every notification from the app that is currently visible in the status bar?

how to know that an app was launch from a click to a notification in the system tray?

When I send an alert notification, if the app is either not running or is in the background, the alert terminates in the system tray. Then later the user clicks on this notification and the app is launched. How can I know that the app was launched from a click on a notification alert in the system tray? And how can I retrieve the information regarding this notification? Also, not that I'm using Firebase cloud messaging.
These similar posts explain how to send and receive messages in the intent:
How to handle notification when app in background in Firebase
get Intent Extra from clicking notification through Firebase

How to get a notification automatically processed by the app when received in HMS Push Kit and React Native?

I am using react-native v0.61.5 and latest versions of react-native-hms-push (App) and hms-push-serverdemo-nodejs.
My server app is able to send both Notification Messages both Data Messages.
What is unclear to me, is how messages must be implemented in order to have this:
when app is in a killed state: a messages is received, sounds on and a bubble appears, the user taps on the notification bubble, the App processes the notification payload while opening
when app is in a killed state: a messages is received, sounds on and a bubble appears, the user opens the App without tapping on the notification bubble, the App processes the notification payload while opening
when app is in a background state: a messages is received, sounds on and a bubble appears, the user opens the App without tapping on the notification bubble, the App processes the notification payload while opening
when app is in background state: a messages is received, sounds on and a bubble appears, the user opens the App without tapping on the notification bubble, the user opens the App without tapping on the notification bubble, the App processes the notification payload while opening
when app is in foreground state: a messages is received, sounds on and a bubble DOES NOT appears, (there are no bubbles to be tapped), the App processes the notification payload suddenly
We encountered some difficulties to satisfy all these 5 requirements listed above. What we have to send from server-side? Data Messages or Notification Messages?
We also tried to use:
let message = {
notification: {...},
android: {androidConfig..., notification: {foreground_show: [false|true]}},
token: new Array(pushDeviceToken)
};
both:
let message = {
data: notification,
android: {androidConfig..., notification: {foreground_show: [false|true]}},
token: new Array(pushDeviceToken)
};
But is seems that there is no the best option...
One more thing: it seems that foreground_show does not works for Notification Messages, when I keep the App in opened state and send a Notification Message with foreground_show: true, no bubble appears and the notification is not processed by the App.
The cause could also be a bad configuration on the App side. It is not very clear how to configure it, since we are new to HMS Push Kit.
Update
If the App is in a killed state, the push Data Messages notifications may cannot be received. If you do need to use the data message, you can apply for the Special Permissions of High-priority data messages.
But at the same time, the application conditions are strict, and it may difficult to pass.
Notification Messages can be triggered only after a user clicks the notification.
Therefore, For the "Notification Messages are not automatically processed by the App if it is in foreground state" scenario you mentioned,It is recommended that you first use the server interaction to cover the foreground scenario. If a message cannot be processed due to application in the background or Kill-State, use Notification Messages.
when app is in a killed state: a messages is received, sounds on and a bubble appears, the user taps on the notification bubble, the App processes the notification payload while opening
In common notification messages, you can choose Message > Notification > data to set the customized parameters (payload). When an application is opened, the onNotificationOpenedApp event can be invoked to obtain related content.
when app is in a killed state: a messages is received, sounds on and a bubble appears, the user opens the App without tapping on the notification bubble, the App processes the notification payload while opening
It is recommended that the app obtains related information through the connection to the application server when the app is started and clears existing notifications when the app is started (a native Android function).
when app is in a background state: a messages is received, sounds on and a bubble appears, the user opens the App without tapping on the notification bubble, the App processes the notification payload while opening
It is recommended that the app obtain related information through the connection to the application server and clear existing notifications during startup (a native Android function).
when app is in background state: a messages is received, sounds on and a bubble appears, the user opens the App without tapping on the notification bubble, the user opens the App without tapping on the notification bubble, the App processes the notification payload while opening
Same as the previous question.
when app is in foreground state: a messages is received, sounds on and a bubble DOES NOT appears, (there are no bubbles to be tapped), the App processes the notification payload suddenly
You can perform the configuration by referring to the following guide:
https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides-V5/android-fgrd-show-0000001050040126-V5?ha_source=hms1

Is there a way to get notification data if user opens application from launcher without clicking notification?

I have got notification from FCM. And i have opened the app from launcher without clicking the notification. So i dont get the notification data in activity. Is there a way to get notification data if user opens application from launcher without clicking notification?
It totally depends upon the app status to get notification data without clicking on Notification,
onMessageReceived is provided for most message types, with the following exceptions:
Notification messages delivered when your app is in the background.
In this case, the notification is delivered to the device’s system tray. A user tap on a notification opens the app launcher by default.
Messages with both notification and data payload, both background and foreground.
In this case, the notification is delivered to the device’s system tray, and the data payload is delivered in the extras of the intent of your launcher Activity.
I shared this data just to inform you that the answer provided by #Sagar Zala will not work when your app is in Background
FCM onMessageReceived Documentation
You can not directly get notification data if you opens app from launcher icon.
But in this case you can store notification data in SQLite or Shared Preference while notification arrive and use this data when you opens app from launcher icon.
Note: Clear notification data once app opens.
Thanks.

how to get push notification payload data when the app is in background in ionic framework,

Hi I'm able to get the push notification in my ionic android app. I can get the push notification when app is running or in background or closed.
I am alerting the notification payload data. When app is running when I send the push notification to the app I'm getting the alert with payload data.
When the app is in background or closed I get the notification. When I tap on the notification in the notification tray (i got to the app via notification tray ). I get the alert in the app when app opens.
But when app is in background or closed, I get the notification but when I got to the app via app icon or recent apps(not tapping the notification in the tray) I cannot get the alert.
I want to get the payload data when I go to the app by tapping the icon or recent apps too.
Please help me.

Categories

Resources