1

I am implementing Cloud Messaging inside my android app. It was so easy until I encountered a big problem: My app seems to work fine and receive messages properly on Samsung devices but on my own device (that happens to be Huawei P9) the app some times doesn't receive any messages. Fortunately I found the problem: when I exit my App and turn off the screen, or clearing the recent apps, my app clears from background and never receives any messages again! (too bad! Why is that?!)

But if I goto Settings->Advanced->Battery->ProtectedApps and check my app as "Protected", my app would received messages even after truing off the screen and/or clearing recent apps. Very good indeed!

Now my question is: Is there anyway to make my app protected? I know there is some way however because when I went to Settings->Advanced->Battery->ProtectedApps many apps (such as Telegram, WeChat, etc) where protected by default! If there is no way to do such thing, how can my app receive notifications?

I also know that some apps like Facebook and ShareIt are installed on my device and are NOT PROTECTED but still receive notifications. How is that?

Bardia
  • 155
  • 1
  • 2
  • 13
  • 1
    Possible duplicate of ["Protected Apps" setting on Huawei phones, and how to handle it](https://stackoverflow.com/questions/31638986/protected-apps-setting-on-huawei-phones-and-how-to-handle-it) – Dewi Morgan Oct 04 '18 at 22:18
  • I couldn't solve my problem by those threads, I want my app to be automatically protected, or some how run on the background on huawei devices. those threads offers to show phone manager and let the user to protect my app which is undesirable – Bardia Oct 04 '18 at 23:11
  • I may be misunderstanding, but it seems that Aiuspaktyn's answer says that developers *can't* auto-protect their apps: it's something that Huawei turns on for popular applications like Tinder. The other posts are people giving workarounds for this problem. – Dewi Morgan Oct 05 '18 at 15:27
  • @DewiMorgan thank you for the answer. so it seems that push notification is going to be obsoleted for freelancers? – Bardia Oct 06 '18 at 16:47
  • It does seem that way, unless the workarounds work for you. Perhaps keep your app running wiht a sticky notification or something? – Dewi Morgan Oct 08 '18 at 19:53
  • for reference: https://dontkillmyapp.com/ – Martin Zeitler Feb 06 '19 at 19:43

1 Answers1

0

I turns out that if you publish your app on Google Play Store and then download it from there, the phone puts the app on ProtectedApps by default.

Bardia
  • 155
  • 1
  • 2
  • 13