Уведомление: кнопка действия не отображается, когда приложение находится в фоновом режиме - PullRequest
0 голосов
/ 09 января 2020

Когда приложение находится в фоновом режиме, я не могу получить кнопки действий в уведомлении. Работает только когда приложение на переднем плане.

notificationManager.createNotificationChannel(notificationChannel)

val builder = NotificationCompat.Builder(this, getString(R.string.channel_id))
builder
        .setStyle(NotificationCompat.BigTextStyle(builder)
        .bigText(message)
        .setBigContentTitle(title)
        .setSummaryText(getString(R.string.app_name)))
        .setContentTitle(title)
        .setContentText(message)
        .setSmallIcon(R.drawable.ic_notification)
        .setLargeIcon(BitmapFactory.decodeResource(this@FirebaseService.resources, R.mipmap.ic_launcher))
        .setSound(defaultSoundUri)
        .setFullScreenIntent(null, true)
        .setAutoCancel(true)
        .setChannelId(getString(R.string.channel_id))
        .setColor(ContextCompat.getColor(applicationContext, R.color.colorPrimary))
        .setPriority(NotificationCompat.PRIORITY_HIGH)
        .setContentIntent(pendingIntent)
        .addAction(R.drawable.ic_notification, "Test", pendingIntent)

val nm = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
nm.notify(0, builder.build())
...