Handling data messages

Check whether the data message is received in the foreground.

  1. Add debug logs to the onMessageReceived callback as shown in the quickstart sample.
  2. Connect your test device to your computer and use adb logcat to stream the logs.
  3. Make sure your app is in the foreground when you're sending the message.
  4. Send a message with a data payload.
  5. Check whether the onMessageReceived log is triggered.
Check whether the data message is received in the background on the Android device
  1. Add debug logs to the onMessageReceived callback.
  2. Connect your test device to your computer and use adb logcat to stream the logs.
  3. Make sure your app is not in the foreground when you're sending the messages.
  4. Send a message with only data payload.
  5. You should see a log with your data payload.
  6. If you're unable to receive background messages, make sure that your app is not force stopped by running: adb shell pm dump your.package.name | grep stopped. If you see stopped=true, your app is force stopped. To learn more about restrictions on stopped applications, see Launch controls on stopped applications.

Your next step depends on whether your app is force stopped or not.