私はアンドロイド5.1デバイスでFCM通知を表示するための以下のメソッドを書きました。 FirebaseMessagingServiceの中でコードを実行すると、ただ1行の通知が与えられます。ここでは、アクティビティ内で展開可能な通知を与える同じコードを実行します。BigTextStyle通知がFirebaseMessagingServiceから拡張されていません
部分的な通知テキストを表示するのではなく、通知で拡張するために、基本的に長いFCMテキスト通知が必要です。
すべてのリードはありますか?
private void showNotif(String messageBody){
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);
// Constructs the Builder object.
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(getString(R.string.app_name))
.setContentText(messageBody)
.setDefaults(Notification.DEFAULT_ALL) // requires VIBRATE permission
.setAutoCancel(true)
.setContentIntent(pendingIntent)
/*
* Sets the big view "big text" style and supplies the
* text (the user's reminder message) that will be displayed
* in the detail area of the expanded notification.
* These calls are ignored by the support library for
* pre-4.1 devices.
*/
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(messageBody));
// android.support.v4.app.NotificationManagerCompat mNotifManager = (NotificationManagerCompat) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
mNotificationManager.notify(0, mBuilder.build());
}
はあなたFirebaseMessagingServiceをトリガしている大丈夫でしょうか? – mgcaguioa
はい。私は両方のケースでそれを試しました。同じ結果。 –
愚かな質問ですが、どちらの場合でも通知トレイの上部にあるのは間違いありませんか? – IanS