I'm trying to get The data from the Notification when the App is Killed or in background here is what I've did : php side :
$msg = array
(
'body' => $msg,
'title' => $title,
'click_action' => "OPEN_ACTIVITY_1"
);
$fields = array
(
'to' => $token,
'notification' => $msg
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
in my luncher Activity :
if(getIntent().getExtras()!=null){
Strig msg = getIntent().getExtras().getString("body");
String title =getIntent().getExtras().getString("title");
Log.i(TAG,"Message "+msg);
Log.i(TAG,"Title " +title);
}
it's Returning null for both msg and title .. here is the code for onMessageReceived()
public void onMessageReceived(RemoteMessage remoteMessage) {
clickAction= remoteMessage.getNotification().getClickAction();
NotificationHelper h = new NotificationHelper(this);
Map<String,String >data = remoteMessage.getData();
title=data.get("title");
msg=data.get("body");
Log.i(TAG, "onMessageReceived: "+clickAction);
h.createNotificationWithId(msg,title,clickAction);
}