Я использую этот класс для управления уведомления в мой Android Appандроид - Firebase уведомления Push уведомление getSubText
public class NotificationMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
String title = remoteMessage.getNotification().getTitle();
String message = remoteMessage.getNotification().getBody();
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder nb = new NotificationCompat.Builder(this);
nb.setContentTitle(title);
nb.setContentText(message);
nb.setSmallIcon(R.drawable.iconanotifica);
nb.setAutoCancel(true);
nb.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000});
nb.setLights(Color.BLUE, 3000, 3000);
nb.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, nb.build());
}
}
в NotificationComapt.Builder, есть метод, который называется: setSubText(), что я хочу использовать. Итак, как мне получить "remoteMessage.getNotification(). GetSubText()"?
Да, это работает. Но я отправляю уведомление с помощью приложения android, и это управляется файлом php. Только если я отправлю уведомление из базы данных, я вижу subText, но не если я отправлю из приложения. Вы можете помочь? – Simone
Эй @ Симон, не могли бы вы расширить вопрос? Если это отдельный экземпляр оригинала, то обновите свой вопрос или просто примите мой ответ и создайте новый поток. – weneedweeds
Нет, это не решение, за которым я хочу следовать. Мне нужно отправить это уведомление из приложения Android и установить подтекст – Simone