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

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

Related

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.

Can Android apps automatically receive push notification content when it's delivered while the app is in foreground?

I'm an iOS developer and this behavior is natural in iOS. If the app is in foreground and there's push notification for the app, the app will receive the push notification content instead of the OS create push notification in the notification center. Now I want to help my fellow Android developer to do the same, but we don't know where to look. As far as he knows, Android app will never receive push notification unless the user tap on the push notification, even if the app is in foreground. We need this so we can refresh the chat screen when we receive push notification from the server that a new chat message is coming. Can this behavior emulated in Android? All this time, the way he retrieved new chat message is that every 5 seconds he queries the server for new messages.

FCM: I have used FCM to receive notification for my app. When my app is in foreground it groups all notifications but not when app is in background

I am able to group notifications for my app when it is in foreground. Whenever the app goes in background it creates multiple notification. How can I fix this?
As google says in this site, when app is in background notifications are administrated by the system by default :
Notifications 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.
But if you want to work with the notifications by "yourself" you should send the 'data message' instead of the 'notification' as is said here and you can handle the notification.

Inactive App Notification: How to configure if a sound should be played or not

I have implemented GCM in my app. The user can configure if notifications should be displayed within the app. I have implemented GcmListenerService to create a notification within onMessageReceived.
However, this only works as long as the app is active. As soon as the app is inactive, Android takes over and displays the notification. What is the recommended way to configure if notifications should be displayed or not when a GCM message is being sent?

Can a push message sent by google cloud messaging be hidden from the app user?

I'm just going through the concept options of the Google Cloud Messaging System https://developers.google.com/cloud-messaging/concept-options and I saw this:
App behavior when receiving messages that include both notification and data payloads
depends on whether the app is in the background, or the foreground —essentially,
whether or not it is active at the time of receipt.
- When in the background, apps receive the notification payload in the notification tray,
and only handle the data payload when the user taps on the notification.
- When in the foreground, your app receives a bundle with both payloads available.
Is it possible to send a push message to specific android device and then verify its content by the app's logic?
And then if the content is verified by the app and it's correct - notify the user, in other case stay silent, dismiss the push msg and don't even show the notification icon?
Thanks!
You have to track the gcm type, for what such gcm gets called, depend on that you can show & hide notifications.
To show notification to user for push the control is in your hand only. Just apply the check that you want to and if the condition satisfies only then generate the notification.

Categories

Resources