Why Your Android Push Notifications Are Getting Swallowed by the Void

If you‘re an Android developer, you‘ve probably put a considerable amount of effort into implementing push notifications for your app. You‘ve carefully followed the Firebase Cloud Messaging (FCM) documentation, written your server-side logic to send notification payloads, and extensively tested to ensure everything works as expected. And yet, you may find that a significant portion of your users never receive your carefully crafted notifications. What gives?

As it turns out, the delivery of push notifications on Android is far from guaranteed. There are numerous points of failure along the delivery path that can lead to notifications being silently dropped, never to be seen by the user. In this post, we‘ll dive deep into the technical details of how push notifications work on Android, explore the most common reasons for delivery failures, and discuss potential solutions and workarounds.

The Life and Times of an Android Push Notification

To understand why push notifications sometimes fail to arrive, it‘s helpful to have a clear picture of the journey a notification takes from your server to the user‘s device. Here‘s a high-level overview of the process:

  1. Your app‘s server sends a notification payload to the FCM server.
  2. FCM receives the payload and routes it to the appropriate Android device based on the included registration token.
  3. The Android device receives the notification payload from FCM.
  4. The Android system wakes up your app‘s background service to handle the incoming notification.
  5. Your app‘s background service displays the notification to the user.

This all seems straightforward enough, but there are several potential failure points along this path. Let‘s explore some of the most common ones.

The Background Service Wake Up Call

One of the most critical steps in the notification delivery process is when the Android system attempts to wake up your app‘s background service to handle the incoming notification. This is done using a mechanism called a wakelock, which essentially tells the device to keep the CPU awake long enough for your service to do its work.

However, device manufacturers often modify Android‘s default behavior in ways that can interfere with this wake up process. In an effort to prolong battery life, many manufacturers include their own custom battery optimization software that aggressively kills background services when the app is not in active use. If your app‘s background service has been killed, it won‘t be able to respond to the wake up call, and the notification will be lost.

The Whitelist Lottery

You might be wondering, if this is such a common problem, why do notifications from some apps seem to always come through reliably? The answer often lies in a special whitelist maintained by the device manufacturer.

This whitelist typically includes Google‘s own apps as well as a small number of highly popular third-party apps. Apps on this whitelist are exempted from the most aggressive battery optimization measures, allowing their background services to always be woken up when needed.

Unfortunately, the exact criteria for inclusion on these whitelists are not public, and the process for requesting inclusion is often opaque at best. For the vast majority of developers, getting your app whitelisted is simply not a realistic option.

The Scale of the Problem

Just how many users are potentially affected by these notification delivery issues? Let‘s look at some statistics:

According to StatCounter, the top Android device manufacturers worldwide as of May 2021 are:

  1. Samsung (31.73%)
  2. Xiaomi (16.56%)
  3. Huawei (10.21%)
  4. Oppo (9.76%)
  5. Vivo (7.69%)

Of these top manufacturers, Samsung, Xiaomi, Huawei, and Oppo are all known to use aggressive battery optimization techniques that can interfere with push notification delivery.

In a survey of over 1,500 Android users, 70.5% reported using a device from a manufacturer known to have problematic battery optimization defaults. This suggests that the majority of Android users worldwide are potentially affected by these issues.

The Manufacturer Maze

One of the biggest challenges in addressing notification delivery issues on Android is the sheer diversity of device manufacturers and customized Android versions in the wild. Each manufacturer tends to have its own unique set of battery optimization features and settings, often with confusing or inconsistent naming.

For example, on Xiaomi devices, you need to navigate to the "Apps battery saver" settings and set the relevant apps to "No restrictions" to ensure reliable notification delivery. On Huawei devices, the same functionality is found under "Protected apps", while on Oppo devices it‘s called "Startup manager". The situation is further complicated by the fact that these settings may have different names and locations even across different device models from the same manufacturer.

This fragmentation makes it incredibly difficult for developers to provide clear and consistent instructions to users on how to troubleshoot notification issues. What works for one device model may be completely different for another.

The iOS Advantage

It‘s worth noting that these notification delivery issues are largely unique to Android. On iOS, push notifications are delivered through Apple‘s servers (APNS) and don‘t rely on a background service on the device. As a result, iOS notifications are generally much more reliable and consistent.

This reliability difference is one of the factors contributing to the perception of Android as a second-class citizen for app development. Many developers prioritize iOS over Android simply because they know their core features like push notifications will work more predictably.

Potential Solutions and Workarounds

So what can you do as a developer to mitigate these Android push notification issues? Unfortunately, there‘s no perfect solution, but here are a few strategies that can help:

1. Educate Your Users

One of the most effective things you can do is to educate your users about the potential for notification issues and provide clear instructions on how to troubleshoot. This can include:

  • A detailed FAQ or troubleshooting guide on your website or in your app
  • In-app messages or UI elements that alert users if notifications are being blocked
  • Device-specific instructions with screenshots for adjusting battery optimization settings

2. Use a Notification Delivery Service

There are several third-party services that aim to improve notification delivery rates on Android by maintaining their own device-level whitelists and fallback delivery channels. Examples include OneSignal and Airship.

These services can be effective, but they do add complexity to your app and may require significant changes to your notification infrastructure.

3. Implement Backup Delivery Channels

For critical notifications, you may want to implement backup delivery channels such as SMS or email. While not ideal, this can provide a fallback option for users who are not receiving your notifications through the normal channels.

4. Advocate for Change

Finally, as developers, we can advocate for changes to Android and manufacturer practices that contribute to these notification issues. This can include filing bug reports, engaging with Google and manufacturer developer relations teams, and supporting organizations like the Android Alliance that are working to address these types of ecosystem challenges.

Looking to the Future

There are some indications that Google is aware of the notification delivery challenges on Android and is working to address them.

In Android 11, Google introduced new APIs that allow apps to display notifications in the status bar even when the app is not running. This could potentially help mitigate the impact of aggressive background service killing.

Furthermore, there are rumors that future Android versions may include more standardized battery optimization settings and whitelisting criteria. However, the details and timeline for these changes remain uncertain.

Conclusion

Push notification delivery on Android is a complex and often frustrating challenge for developers. The fragmentation of the Android ecosystem and the prevalence of aggressive manufacturer battery optimizations can lead to notifications being silently dropped for a significant portion of users.

As developers, our best option is often to educate users, provide clear troubleshooting instructions, and implement fallback delivery mechanisms where necessary. We can also advocate for ecosystem-level changes and support ongoing efforts to address these issues.

While there‘s no perfect solution, by understanding the technical details of the Android notification system and the common points of failure, we can work to provide the best possible experience for our users. And hopefully, with continued pressure and advocacy, we‘ll see a more reliable and standardized notification delivery system emerge in future Android versions.

Similar Posts