[Update: Public API Removed in Beta 3] Notification Assistants in Android Q can change the priority and buttons of notifications from other apps
Since before Android 8.0 Oreo, Google has worked on a new Notification Assistant API. With the release of the first Android Q beta, Google made the API public and published documentation for it. In the second Android Q beta, it’s now possible to change the default notification assistant from the Android Services Library system app to any third-party app of your choosing. Here’s an early look at the new API and what it can do.
First off, if you installed the Android Q beta on your Google Pixel back in March, you may have briefly seen smart replies and buttons show up in every notification. The app responsible for inserting smart replies is the default notification assistant, though Google quickly disabled the notification assistant’s smart reply functionality via a server-side update. We re-activated the feature to show you what the API is capable of, as shown in the screenshots below.
As you can see, the notification assistant added contextual buttons to messages from the Telegram app. It either showed me smart replies, or in the case of a URL, a link to open the URL in the appropriate app. According to the documentation, a Notification Assistant can adjust the priority or add buttons to any existing notification, before or after they’re posted. Unlike the long-standing Notification Listener API, Notification Assistants keep the existing notification when making adjustments to it. If a notification supports in-line replies, a Notification Assistant app can add buttons to send a response—which is exactly what the platform-default notification assistant does. Since the API is generic, a Notification Assistant can add buttons to notifications, even ones that aren’t from messaging apps, that trigger whatever action you want.
João Dias, the developer of Tasker and AutoApps, is working on an update to his AutoNotification plugin for Tasker that lets you add custom quick replies to any notification. Here’s a video he made showing off the new AutoNotification version that supports the Notification Assistant API:
I can see this API being useful for automation apps, but I don’t think many people will change the default notification assistant. Once Google flips the switch to enable contextual actions and smart replies in the default notification assistant, there will be little reason for people to use a third-party one. Still, fans of automation apps like Tasker may find this new API in Android Q to be useful.
Update 1: Documentation for the API has been removed
Following the release of the third Android Q beta at Google I/O 2019, the Tasker developer reached out to me to inform me that Google removed the public API for the NotificationAssistant feature. Checking the API diff confirms this to be the case. We also spoke to Googlers at I/O and were told that the API wasn’t intended for the public. We’ll update this article if anything changes with the availability of this API.