I installed the notification service in my app, it works, it even receives notification in the background, but I wanted to save the notification message, I researched a bit and created a service (code below) works, but only when the app is open in foreground), background does not work.
public class FirebaseNotificationService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.i("PVL", "Mensagem Recebida");
if (remoteMessage.getNotification().getBody() != null) {
Log.i("PVL", "Mensagem recebida: " + remoteMessage.getNotification().getBody());
} else {
Log.i("PVL", "Mensagem recebida: " + remoteMessage.getData().get("message"));
}
}
}