class SFMCActionReceiver : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
//Cancel your ongoing Notification
val nm =
context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val notificationIdToCancel = if (intent?.extras != null) intent.extras!!
.getInt(EXTRA_SFMC_NOTIFICATION_ID_FOR_CANCEL_ACTION) else 0
val abridged = if (intent?.extras != null) intent.extras!!.getInt("ASD") else 0
Log.i(
"ASD",
"dismissing sfmc notification Id:$notificationIdToCancel $abridged"
)
nm.cancel( abridged); //doesnt work
nm.cancel( notificationIdToCancel) //doesnt work
nm.cancelAll() //works
}
}
Отмена уведомления посредством отмены не работает, пока cancelAll очищает все уведомления приложения.
Я передаю идентификаторы уведомлений для отмены
code> для отмены уведомления, но, судя по всему, он не работает.
Я что-то упускаю?
Заранее спасибо.
// If we're running on Android O we create a notification channel if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { builder = new NotificationCompat.Builder(context, context.getString(R.string.default_notification_channel_id)); } else { notificationChannel = new NotificationChannel(SFMC_PUSH_NOTIFICATION_CHANNEL_ID, context.getString(R.string.sfmc_notification_channel), NotificationManager.IMPORTANCE_DEFAULT); getNotificationManager(context).createNotificationChannel(notificationChannel); builder = new NotificationCompat.Builder(context, SFMC_PUSH_NOTIFICATION_CHANNEL_ID); }
if (isMediaAvailable) { bitmapImage = getBitmapfromUrl(notificationMessage.mediaUrl());
override fun onReceive(context: Context?, intent: Intent?) {
//Cancel your ongoing Notification val nm = context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager val notificationIdToCancel = if (intent?.extras != null) intent.extras!! .getInt(EXTRA_SFMC_NOTIFICATION_ID_FOR_CANCEL_ACTION) else 0 val abridged = if (intent?.extras != null) intent.extras!!.getInt("ASD") else 0 Log.i( "ASD", "dismissing sfmc notification Id:$notificationIdToCancel $abridged" )
nm.cancel( abridged); //doesnt work nm.cancel( notificationIdToCancel) //doesnt work
nm.cancelAll() //works
} } [/code] Отмена уведомления посредством отмены не работает, пока cancelAll очищает все уведомления приложения. Я передаю идентификаторы уведомлений для отмены code> для отмены уведомления, но, судя по всему, он не работает. Я что-то упускаю? Заранее спасибо.