FCMメッセージサービスのonMessageReceivedの中に以下のコードを実装して、アプリがフォアグラウンドのときに通知を表示しました。Android - 数秒前に通知トレイを持たせる方法
通知が正しく生成され、正しくトレイに表示されます。 しかし、私の必要条件は、アプリが数秒間前に来るように通知トレイをフォアグラウンドにしてから、デフォルトで非表示にする必要があるということです。これを達成する方法は?
NotificationCompat.Builder notificationBuilder = new
NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_notifications_black_24dp)
.setContentTitle(title)
.setContentText(messageBody)
.setAutoCancel(true)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(2 , notificationBuilder.build());
おかげ
答えがあなたを助けましたか? –