FCM with open app does not get notifications


Well as the title says, my test app with FCM does not get PUSH notifications when I have the app open, if I close the app they arrive normally, which seems strange to me since most people have problems with the app closed and not open, I leave my classes:

public class MiFirebaseInstanceIdService extends FirebaseInstanceIdService {

public static  String TAG = "";

public void onTokenRefresh() {

    String token = FirebaseInstanceId.getInstance().getToken();
    MiFirebaseInstanceIdService.TAG = token;
    Log.d(TAG, "Token: " + token);


private void enviarTokenAlServidor(String token) {
    // Enviar token al servidor


public class MiFirebaseMessagingService extends FirebaseMessagingService {

public static final String TAG = "NOTICIAS";

public void onMessageReceived(RemoteMessage remoteMessage) {

    String from = remoteMessage.getFrom();
    Log.d(TAG, "Mensaje recibido de: " + from);

    if (remoteMessage.getNotification() != null) {
        Log.d(TAG, "Notificación: " + remoteMessage.getNotification().getBody());

        mostrarNotificacion(remoteMessage.getNotification().getTitle(), remoteMessage.getNotification().getBody());

    if (remoteMessage.getData().size() > 0) {
        Log.d(TAG, "Data: " + remoteMessage.getData());


private void mostrarNotificacion(String title, String body) {

    Intent intent = new Intent(this, MainActivity.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);

    Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)

    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(0, notificationBuilder.build());





            <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>

Well how to reconfirm with the CLOSED app if they arrive normally, now if I have the app OPEN I do not get the notifications, Any help Thanks

asked by Bruno Sosa Fast Tag 05.02.2018 в 15:26

1 answer


Maybe it could be because you need to define in your AndroidManifest.xml , your service MiFirebaseMessagingService :

 <service android:name="MiFirebaseMessagingService">
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
answered by 05.02.2018 / 20:35