0

I am trying to trigger onMessageReceive() once app is killed I printed log in on onMessageReceive() but it only showing the notification I am also sending the data payload but still this method is not triggering while app is killed is there any solution?

  public class MyFirebaseMessagingService extends FirebaseMessagingService {

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        // ...

        // TODO(developer): Handle FCM messages here.

        Log.d(TAG, "From: " + remoteMessage.getFrom());

        // Check if message contains a data payload.
        if (remoteMessage.getData().size() > 0) {
            Log.d(TAG, "Message data payload: " + remoteMessage.getData());



        }

        // Check if message contains a notification payload.
        if (remoteMessage.getNotification() != null) {
            Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
        }

        // Also if you intend on generating your own notifications as a result of a received FCM
        // message, here is where that should be initiated. See sendNotification method below.
    }
}
KENdi
  • 7,576
  • 2
  • 16
  • 31
Honey Buny
  • 13
  • 5
  • See my answer [here](http://stackoverflow.com/a/39505298/4625829). – AL. May 10 '17 at 03:53
  • @AL. i have tested this code on my emulator and my huwaie 5x whenever i swipe the app from recent apps i only get notification my onMessageReceived() does not call i want to send commands to my android device to run some service or perform some specific task is there any way? – Honey Buny May 10 '17 at 07:49

0 Answers0