0

Devices like huawei or xiaomi are not receiving push notifications while they are in background. Other brands have not issues. Any ideas what's going on?

Update

  • I can confirm push notification was sent it by server.
  • I did create a new project with Firebase, and still happens the same issue.
Ricardo
  • 7,921
  • 14
  • 64
  • 111
  • Can you confirm if push notification has been successfully fired from server? You should check if device token is generating from these devices while registering for GCM. Also, you should go with FCM (Firebase Cloud Messaging) as GCM will deprecate soon. – Deepak Singh Sep 28 '16 at 08:00
  • I can confirm push notification was sent it by server. – Ricardo Sep 28 '16 at 08:21
  • Why downvote? you can see in other answer is a real problem. – Ricardo Sep 28 '16 at 08:24
  • this is a real problem but it applies to ALL background activities/services of the apps, not just gcm. unfortunately it is unlikely a good fix appears because it is intentional behavior coded in by xiaomi/huawei engineers - and they whitelisted several of the popular apps from getting killed, further adding to the user confusion. furthermore the phone itself makes pretty much no effort to announce to the user what is going on. – Lassi Kinnunen Mar 14 '17 at 06:51

1 Answers1

3

Once you kill application on xiaomi, huawei these phones unregister broadcast receivers, services of the application.

In case of notification, your GCM broadcastreceiver get unregistered on killing app, that is likely the reason for this.

Ajay S
  • 48,003
  • 27
  • 91
  • 111
  • 1
    I confirm with Honor 7 phone, same code works with Nexus 5 – Al Wld Sep 28 '16 at 08:06
  • 1
    @AlWld yup, it is device specific only for xiaomi, huawei. it works rest of other devices – Ajay S Sep 28 '16 at 08:08
  • 1
    How apps like whatsapp deal with it? How can i register again the broadcastreceiver? – Ricardo Sep 28 '16 at 08:31
  • you need to have something cause the app to open again or add it to the protected apps. whatsapp etc. are on a hardcoded list that are whitelisted automatically. it's a stupid solution but thats how huawei is doing things. whatsapp, facebook twitter etc all BIG userbase apps are on the list of "good" apps. it's meant to save battery or something. otoh, as an user, if you kill something it stays closed. you could try to educated your users or add a screen that tells them to put them in the protected apps list on huawei. – Lassi Kinnunen Mar 14 '17 at 06:48
  • You can read more https://github.com/firebase/quickstart-android/issues/41 (for FCM, same issue actually): The answer (which you have nothing to do about it..) is detailed at this post https://github.com/firebase/quickstart-android/issues/41#issuecomment-322154638 – MTZ4 Sep 17 '17 at 08:59