1

Ya he personalizado mi notificacion en primer plano , pero al momento de salirme de la app , se crea una notificacion normal, sin la personalizacion, alguna manera de resolver este problema ??

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID);
        notificationBuilder.setAutoCancel(true)
                .setDefaults(Notification.DEFAULT_ALL)
                .setWhen(System.currentTimeMillis())
                .setSmallIcon(R.drawable.ic_abuso)
                .setPriority(Notification.PRIORITY_MAX)
                .setContentTitle(remoteMessage.getNotification().getTitle())
                .setContentText(remoteMessage.getNotification().getBody())
                .setContentInfo("Information")
                .setContentIntent(pendingIntent);

1 respuesta 1

0

I solved the problem of how to customize the notification in the background, I had to create a backend of the notifications in sending notifications by that means, I sent the notification by means of the api https://fcm.googleapis.com/fcm/send, At the moment of creating the JSON, I do not send title nor description, in the data of the notification I add some variables like title Example and description Example.

When you get the notification, you create it in this way

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID);
        notificationBuilder.setAutoCancel(true)
                .setDefaults(Notification.DEFAULT_ALL)
                .setWhen(System.currentTimeMillis())
                .setSmallIcon(R.drawable.log)
                .setPriority(Notification.PRIORITY_MAX)
                .setContentTitle(remoteMessage.getData().get("title Example"))
                .setContentText((remoteMessage.getData().get("description Example")))
                .setContentInfo("Information")
                .setContentIntent(pendingIntent);

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.