I am trying to implement FCM in my Android app. On a few phones, the notification is received when the app is in foreground/background/killed. But on some phones, it is only received when the app is in foreground/background. When the app is killed, the onMessageReceived and the launcher getExtra is also not called. I am using both the data and notification object from the API. Here is my Android code -
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.e("Here", "here");
if (remoteMessage.getData().size() > 0) {
Log.e(TAG, "Data Payload: " + remoteMessage.getData().toString());
try {
JSONObject json = new JSONObject(remoteMessage.getData());
sendPushNotification(json);
} catch (Exception e) {
Log.e(TAG, "Exception: " + e.getMessage());
}
}
if (remoteMessage.getNotification() != null) {
Log.e(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
}
}