5

私はアンドロイド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()); 
} 
+0

はあなたFirebaseMessagingServiceをトリガしている大丈夫でしょうか? – mgcaguioa

+0

はい。私は両方のケースでそれを試しました。同じ結果。 –

+0

愚かな質問ですが、どちらの場合でも通知トレイの上部にあるのは間違いありませんか? – IanS

答えて

0

これは動作するはずです。 ビッグテキストの通知は、他の通知が上にあるときに通常モードで表示されます。テスト中に展開してみてください。

0

あなたは、このメソッドを使用してhttps://fcm.googleapis.com/fcm/sendクレアーレ通知に必要とfirebaseコンソールを使用して、すべてのアプリがバックグラウンドにあるとき

+0

このリンクは質問に答えるかもしれませんが、答えの本質的な部分をここに含めて参考にしてください。リンクされたページが変更された場合、リンクのみの回答は無効になります。 – ekad

関連する問題