Last active
June 21, 2016 16:36
-
-
Save sab99r/bc8cf03bf0322d2dc91be43e4bf12849 to your computer and use it in GitHub Desktop.
FirebaseMessagingService extended class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class FcmMessageService extends FirebaseMessagingService{ | |
| @Override | |
| public void onMessageReceived(RemoteMessage remoteMessage) { | |
| //onMessageReceived will be called when ever you receive new message from server.. (app in background and foreground ) | |
| Log.d("FCM", "From: " + remoteMessage.getFrom()); | |
| if(remoteMessage.getNotification()!=null){ | |
| Log.d("FCM", "Notification Message Body: " + remoteMessage.getNotification().getBody()); | |
| } | |
| if(remoteMessage.getData().containsKey("post_id") && remoteMessage.getData().containsKey("post_title")){ | |
| Log.d("Post ID",remoteMessage.getData().get("post_id").toString()); | |
| Log.d("Post Title",remoteMessage.getData().get("post_title").toString()); | |
| // eg. Server Send Structure data:{"post_id":"12345","post_title":"A Blog Post"} | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment