I cannot open a message sent by firebase

Asked

Viewed 28 times

0

I can send a firebase notification to my App but I can’t Open that same notification within the actidity responsible for the arrival of that notification

1 answer

0

 private void createNotification( String messageBody) {
    Intent intent = new Intent( this , ResultActivity. class ); // AQUI VC CHAMA A ACTIVITY PARA ENTRAR QUANDO CLICAR NA NOTIFICAÇÃO!
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent resultIntent = PendingIntent.getActivity( this , 0, intent,
            PendingIntent.FLAG_ONE_SHOT);

    Uri notificationSoundURI = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder mNotificationBuilder = new NotificationCompat.Builder( this)
            .setSmallIcon(R.mipmap.ic_launcher)
            .setContentTitle("titulo")
            .setContentText(messageBody)
            .setAutoCancel( true )
            .setSound(notificationSoundURI)
            .setContentIntent(resultIntent);

    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0, mNotificationBuilder.build());
}

To call the function use

createNotification(remoteMessage.getNotification().getBody())

Browser other questions tagged

You are not signed in. Login or sign up in order to post.