package com.team_htbr.a1617proj1bloeddonatie_app;

import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import android.util.Log;

import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;

/**
 * Created by Ruben on 23/03/2017.
 */

public class MyFirebaseMessagingService extends FirebaseMessagingService {
	private static final String TAG = "MyFirebaseMsgService";

	@Override
	public void onMessageReceived(RemoteMessage remoteMessage) {

		Log.d(TAG, "FROM:" + remoteMessage.getFrom());

		//Check if the message contains data
		if(remoteMessage.getData().size() > 0) {
			Log.d(TAG, "Message data: " + remoteMessage.getData());
		}

		//Check if the message contains notification

		if(remoteMessage.getNotification() != null) {
			Log.d(TAG, "Message body:" + remoteMessage.getNotification().getBody());
			sendNotification(remoteMessage.getNotification().getBody());
		}
	}

	/**
	 * Dispay the notification
	 * @param body
	 */
	private void sendNotification(String body) {

		Intent intent = new Intent(this, MainActivity.class);
		intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

		PendingIntent pendingIntent = PendingIntent.getActivity(this, 0/*Request code*/, intent, PendingIntent.FLAG_ONE_SHOT);
		//Set sound of notification
		Uri notificationSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

		NotificationCompat.Builder notifiBuilder = new NotificationCompat.Builder(this)
			.setSmallIcon(R.mipmap.ic_launcher)
			.setContentTitle("Firebase Cloud Messaging")
			.setContentText(body)
			.setAutoCancel(true)
			.setSound(notificationSound)
			.setContentIntent(pendingIntent);

		NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
		notificationManager.notify(0 /*ID of notification*/, notifiBuilder.build());
	}
}

package com.team_htbr.a1617proj1bloeddonatie_app;

import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import android.util.Log;

import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;

/**
 * Created by Ruben on 23/03/2017.
 */

public class MyFirebaseMessagingService extends FirebaseMessagingService {
	private static final String TAG = "MyFirebaseMsgService";

	@Override
	public void onMessageReceived(RemoteMessage remoteMessage) {

		Log.d(TAG, "FROM:" + remoteMessage.getFrom());

		//Check if the message contains data
		if(remoteMessage.getData().size() > 0) {
			Log.d(TAG, "Message data: " + remoteMessage.getData());
		}

		//Check if the message contains notification

		if(remoteMessage.getNotification() != null) {
			Log.d(TAG, "Message body:" + remoteMessage.getNotification().getBody());
			sendNotification(remoteMessage.getNotification().getBody());
		}
	}

	/**
	 * Dispay the notification
	 * @param body
	 */
	private void sendNotification(String body) {

		Intent intent = new Intent(this, MainActivity.class);
		intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

		PendingIntent pendingIntent = PendingIntent.getActivity(this, 0/*Request code*/, intent, PendingIntent.FLAG_ONE_SHOT);
		//Set sound of notification
		Uri notificationSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

		NotificationCompat.Builder notifiBuilder = new NotificationCompat.Builder(this)
			.setSmallIcon(R.mipmap.ic_launcher)
			.setContentTitle("Bloeddonatie")
			.setContentText(body)
			.setAutoCancel(true)
			.setSound(notificationSound)
			.setContentIntent(pendingIntent);

		NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
		notificationManager.notify(0 /*ID of notification*/, notifiBuilder.build());
	}
}

Change notification title