1. 程式人生 > >Notifications in Android are horribly broken

Notifications in Android are horribly broken

Notifications in Android are horribly broken

Android is the most popular mobile operating system now with more than 76% market share. This has, in part, been possible due to its open nature and the multiple vendors which ship Android on their devices. But it also has huge problems in terms of fragmentation. For e.g Android Oreo was released in August 2017 and iOS 11 was released in September 2017, Oreo has 14.2% market adoption and iOS 11 has 85% even though Oreo had a headstart. To get to 85% adoption, you need to target Android Kitkat which was released in Oct 2013. Though this is only the tip of the iceberg.

Missing Notifications

I used to work at Flock as the Head of Android Development and we started receiving some peculiar complaints from users about missing notifications. Since we were a team messaging app which competes with slack, notifications were critical. We double checked our push notifications sending services and verified multiple libraries, but there wasn’t an issue with those. We eventually drilled down the issue to certain Chinese manufacturers namely Xiaomi, Oneplus, Meizu etc.

Autostart

Autostart settings screen on Xiaomi

In Android, a push notification wakes up an application/service which in turn displays the push notification. In case an application is force killed, then the system will not wake up the application. We discovered that on some devices like Xiaomi , our app would not wake up at all and by default started as force-killed. The only way to avoid this was to be a part of an ‘autostart’ list, which denoted apps which could wake up ( ‘auto start’ ) after being closed.

Though for convenience, manufacturers choose to auto add popular applications like Facebook , Whatsapp etc by default. And since we were an upcoming startup there was no way we could make it in there by default. Since a significant chunk of our users were from India, the complaints kept getting more frequent as we got more users and people started posting negative reviews. We had to find a solution. We also realized that this was pretty common, there are multiple websites which have FAQ pages dedicated to making notifications work on Android. For e.g. Hike , Forbes , AndroidCentral etc .

Getting in touch with manufacturers

We tried contacting phone manufacturers directly to be included in their autostart list. We tried Twitter, their support channels and emails were pretty much useless since all we got were front-line customer support executives who had no clue about this. We were able to utilize our CEO’s contacts and got in touch with management from a certain manufacturer who directed us to their engineering team. Their engineering team asked us to share our apk, ran a few tests and we were whitelisted. Complaints stopped for a particular manufacturer, but there were still many others who continued to face this issue.

Using double-acks to detect missed pushes

To solve the problem, we first had to figure out which users are missing notifications. While the standard HTTP GCM Push API doesn’t give you delivery receipts, the XMPP API does. GCM delivery receipts essentially tell you whether the device received the push notification or not. We coupled this with duplicate notification delivery receipts from inside of the app. So any device where we got ack’s from GCM but not from the device, was potentially missing pushes. Once the devices were identified, we started sending them bot messages on how to add flock in their device’s auto-start list.

Architecture to determine missed pushes

Conclusion

Android is an incredibly fragmented ecosystem, which only seems to be getting more fragmented. While Google is making some determined efforts to solve this via Project Treble and other initiatives, it cannot stop manufactures from adding additional features like autostart. Autostart helps slower devices feel faster by keeping fewer apps in memory and manufactures of low-end devices will continue to use it. Android seems to be following the footsteps of Desktop Linux , with every manufacturer essentially creating their own custom distribution. The future for Android only seems to be only more fragmented.