简体   繁体   English

Android中是否有用于“用户阻止我们的通知”的API?

[英]Is there an API for “users blocking our notifications” in Android?

As a app designer, the worst thing is having my app unstalled. 作为应用程序设计师,最糟糕的事情是让我的应用程序崩溃。 Second-worst is having my notifications blocked. 其次,我的通知被阻止了。 If many users are blocking our app's notifications, I want to know early and often. 如果许多用户阻止了我们应用程序的通知,我想早点,经常地知道。

Seems like apps can know if they're blocked (NotificationListener?), but it's not clear how to measure percentage of users blocking my app. 似乎应用可以知道它们是否被阻止了(NotificationListener?),但是尚不清楚如何衡量阻止我的应用的用户百分比。 I was surprised to find no existing API in Google Analytics or Android's APIs for this. 我很惊讶在Google Analytics(分析)或Android的API中找不到现有的API。

When I can't find an API for something I presume is really important, it makes me worry there's some other way to get that info that I don't know about. 当我找不到我认为很重要的API时,这让我担心还有其他方法可以获取我不知道的信息。 Is there? 在那儿?

You can use the NotificationManagerCompat.areNotificationsEnabled() method to determine if your notifications are blocked. 您可以使用NotificationManagerCompat.areNotificationsEnabled()方法来确定通知是否被阻止。

Keep in mind that this only will return false on Kitkat or above devices - prior to that, it was not possible to determine if you blocked (even though blocking notifications was added in Jellybean MR2). 请记住,这只是将返回false的奇巧或以上的设备-在此之前,这是不可能的,以确定是否阻塞(即使阻通知在杰利贝恩MR2添加)。

Of course, as detailed in the What's new with Notifications I/O 2016 talk , this should only be used for catching edge cases (like on a notification settings page) and not for telling the user that they must re-enable notifications. 当然,正如“ 通知I / O 2016的新增功能”中所述,此属性仅应用于捕获极端情况(例如在通知设置页面上),而不能用于告知用户必须重新启用通知。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM