Changes to Web Notifications in Android O
This is a brief service announcement of some impending changes to Notifications on browsers running on Android O.
Recently the Android team published a developer preview of Android O and some of the changes affect browsers abilities to support the Notification API.
There is a requirement that apps targeting Android O must use “Notification Channels”.
Notification Channels provide a method for app developers to group their notifications into “channels”. With this, Android can provide a UI for users to set notification preferences against each channel.
Taken from the Android documentation on Notification Channels:
When a user modifies the behavior for any of the following characteristics, it applies to the notification channel:
- Importance
- Sound
- Lights
- Vibration
- Show on lockscreen
- Override do not disturb
Browsers on Android will need to use this new API when they target Android O, but this has ramifications on the browser’s ability to support the spec’d Notification API. Using Chrome Dev on Android O you may find that the “vibration” and “silent” options in notifications no longer behave as they used to.
For those unfamiliar to the Notifications API, the vibration option allows developers to define a vibration pattern when a notification is shown and the silent option would display a new notification without vibrating or playing a sound on the device.
On Android O, both of these options have no effect and the default sound and vibration settings are used. In Chrome 58, there is one channel for all web notifications. By Chrome version 60 there should be one channel per origin.
If you have an Android O device and a pre-Android O device you can compare the differences by clicking the vibration and silent notification demos here. What you’ll notice is that on pre-O versions of Android, vibration will work regardless of volume level and silent will always result in no sound or vibration. Regardless of the vibration or silent options, notifications on Android O will play a sound if the volume is > 0, otherwise it’ll vibrate when volume is at 0.
This change will only affect browsers that support vibrate, silent and / or sound notification options. For example Firefox on Android doesn’t currently have support for these options so is unaffected whereas Chrome supported the vibrate and silent options.
Chrome will hopefully update to reflect lack of support via the normal feature detect for notification features:
At the moment this feature detect doesn’t work *sad trombone*, but you can track changes for this issue here.