My application has to recieve notification from Amazon SNS. Howerver, In the tutorial from this, I have to use Google Cloud Messaging to implement. I found that Google encourages developer to migrate from Google Cloud Messaging to Firebase Cloud Messaging, so I decide to choose Firebase Cloud Messaging. The problem is when I push notification from Amazon console to my Application, it throws an Null pointer exception in the last line of code below.
public void onMessageReceived(RemoteMessage remoteMessage) {
// TODO(developer): Handle FCM messages here.
// If the application is in the foreground handle both data and notification messages here.
// 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.
Log.d(TAG, "From: " + remoteMessage.getFrom());//getFrom() method returns right outcome
Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody());
}
How can I fix it? Thanks
Anil DS
use remoteMessage.getData();