1

Attempt to receive data message from HMS Push Kit when my app is closed.

I am able to receive data message when app is foreground:

// Registering
componentDidMount(){
   this.listener = HmsPushEvent.onRemoteMessageReceived(event => {
      const RNRemoteMessageObj = new RNRemoteMessage(event.msg);
      const msg = RNRemoteMessageObj.parseMsgAllAttribute(event.msg);
      console.log("Data message received : "+msg);
   }
}
 
// Unregistering
componentWillUnmount(){
   this.listener.remove(); 
}

By using this method I wont able to receive the data message when app is closed since the listener had removed.

Any ideas?

Jeffy Lee
  • 87
  • 2
  • 9

1 Answers1

0

Push Kit supports two types of messages: notification messages and data messages. 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. 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.

To allow users to open a specified page of your app after they tap a notification message, please kindly refer to: 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.

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108