2

I want to know the remoteMessage from HmsMessageService is a message data with or without notification, how to judge the difference between them?

public class HmsService extends HmsMessageService {

  @Override
  public void onMessageReceived(RemoteMessage remoteMessage) {
    // Judge if with or without notification.
  }
}
zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
ccd
  • 5,788
  • 10
  • 46
  • 96

1 Answers1

0

Push Kit can process messages based on the destination app's status (running in the foreground or background). If you want the app running in the foreground to receive notification messages or data messages, you need to implement the onMessageReceived method. The app will take subsequent actions after receiving the messages.

For more details, you could refer to this Docs. Feel free to contact us if you have any further questions.

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
  • 1
    Is it possible to judge the remoteMessage is a notification message or a data message in onMessageReceived method? – ccd Oct 08 '21 at 08:47
  • The `onMessageReceived` method is used to receive data messages.The notification message is displayed directly so this method will not be triggered. – zhangxaochen Oct 08 '21 at 09:02
  • Is it mean the only way to get the data from notification message is to tap it? – ccd Oct 08 '21 at 09:05
  • Is it mean the only way to get the data from notification message is to tap it? – ---Yes – zhangxaochen Oct 08 '21 at 09:08