Delayed notification issue on Huawei devices

Over the last couple months we’ve noticed some issue with delayed notifications on some Huawei devices.

In this article we will explain the issue, the cause and some possible fixes.

The issue

This is a known issue with Huawei devices and is being caused by the battery manager and the way it’s trying to save battery.

Possible fixes

There are couple settings that can help.

On Android 5 and lower:

  • Change the power plan to “normal” under settings → power saving
  • Add the app as protected App under settings → Protected apps

On Android 6 and higher:

  • Change the power plan to “normal” under settings → general settings
  • Add the app as protected App
  • Change the optimization setting under settings → apps → advanced → ignore battery optimizations

Huawei power saving setting Huawei protected app setting

Test Application

To investigate this issue further we wrote an application to test delayed notifications on Huawei devices and also on other devices for references. The project can be found under Github.

Notification Test1 Notification Test2

Relevant code

The relevant code for this test case and delayed notifications are the following.

Java
alarmManager.setExact(AlarmManager.RTC_WAKEUP,  System.currentTimeMillis() + 3 * 1000 , pendingIntent);

If you experience similar issues feel free to discuss in the comments.