How to detect a Notification Channel is blocked by user in Android 8.0

独自空忆成欢 提交于 2019-12-07 03:50:32

问题


Is there any callback my application receives when user blocks a Notification Channel created by my application OR it can be detected later ?


回答1:


No, there is no such listener provided by the APIs. You will have to check each time before you make a notification.

From the developer document

To find out if a user blocked a notification channel, you can call getImportance(). If the notification channel is blocked, getImportance() returns IMPORTANCE_NONE.




回答2:


Starting from Android P, there is a system broadcast for this: https://developer.android.com/reference/android/app/NotificationManager.html#ACTION_NOTIFICATION_CHANNEL_BLOCK_STATE_CHANGED

It's impossible to reliably sync our backend push servers with the channel settings without this (you have to poll...)



来源:https://stackoverflow.com/questions/46294474/how-to-detect-a-notification-channel-is-blocked-by-user-in-android-8-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!