/** * Created by thatisusama on 20/3/2015. */ public class MyFirebaseMessagingService extends FirebaseMessagingService { @Override public void onMessageReceived(RemoteMessage remoteMessage) { String var1 = remoteMessage.getData().get("key1"); String var2 = remoteMessage.getData().get("key2"); GetNotification(message, postid); } public void GetNotification(final String var1,final String var2) { NotificationCompat.Builder bd = new NotificationCompat.Builder(MyFirebaseMessagingService.this); //bd.setContentIntent(pendingIntent); bd.setLights(Color.BLUE, 1000, 1000); bd.setSmallIcon(R.mipmap.ic_launcher); bd.setContentTitle("Test_Title"); bd.setContentText(var1); // this intent will open your desired activity on notification click Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.putExtra("YourDesiredName", var2); notificationIntent.addFlags(notificationIntent.FLAG_ACTIVITY_NEW_TASK); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); bd.setContentIntent(contentIntent); bd.setAutoCancel(true); int notificationId = (int) (System.currentTimeMillis()%10000);//this id will be the time to avoid duplicate ids for notifications NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(notificationId,bd.build()); } }