【发布时间】:2016-09-22 20:55:49
【问题描述】:
我使用这个类来管理我的 Android 应用程序中的通知
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 firebase notifications firebase-cloud-messaging