HMS Push plugin - how to receive data message when the app is in killed state

1k views Asked by At

Android - Huawei with HMS push plugin, HmsPushEvent.onRemoteMessageReceived this event was not triggered when app is in killed state. This event only getting called while app is in foreground and background state. Can you please tell which event will be called when app is in killed state.

1

There are 1 answers

0
zhangxaochen On

Push Kit supports two types of messages: notification messages and data messages. After a device receives a data message, the device transfers it to your app instead of directly displaying the message. Your app then parses the message and triggers the corresponding action. Push Kit only functions as a channel, and the delivery of data messages depends on the resident status of your app. However, notification messages can still be delivered even if your app is not launched.

For the sake of saving power and not disturbing users, your app will not be launched by Push Kit after being stopped, and no data messages can be delivered to your app. In this case, you can determine whether to use notification messages based on your services.

To allow users to open a specified page of your app after they tap a notification message, proceed as follows:

  • Generate Intent parameters
  • Set intent in the message body on your app server
  • Register the Activity class to be started in the AndroidManifest.xml file of the app
  • Receive data in the customized Activity class

From: https://stackoverflow.com/a/64100678/14006527

Alternatively, you can set high-priority data messages to forcibly launch your stopped app to receive and process the messages. To do so, you need to apply for special permission by referring to the related description in FAQs.