2
votes

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:

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

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

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

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

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

1

1 Answers

1
votes

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