Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alarmManager.set does not work #6

Open
wellbranding opened this issue Jun 11, 2020 · 13 comments
Open

alarmManager.set does not work #6

wellbranding opened this issue Jun 11, 2020 · 13 comments

Comments

@wellbranding
Copy link

Hello, I have tried using alarManager.set, but it does not work with all devices, particularly with Huawei or Xiaomi. I tried to use setExactAndAllowWhileIdle, but it also does not work if app is closed. What are your suggestions?
Will you update your sample to tackle these issues?

@PatilShreyas
Copy link
Owner

It's problem of Chinese ROMs actually. If you go to the app settings and turn off background restrictions and set autostart ON and remove other restrictions too it'll surely work. I'm also using Xiaomi Phone and tested on it. Try it and LMK if it works

@wellbranding
Copy link
Author

wellbranding commented Jun 12, 2020

Actually it did not helped for all devices. It worked on Pixel 3 XL, but it does not work on Nexus 6P Emulator. Here is what I did:

  1. I created an alarm at particular time.
  2. I ran adb shell dumpsys alarm > dump.txt and it showed Pending Intent
  3. I also checked to the app settings and removed battery optimisation. There weren't any settings like autostart or background restrictions.
  4. Then I swipe app out application.
  5. I ran adb shell dumpsys alarm > dump.txt and no Pending intents were available anymore.

The only solution which actually works is to start foreground service. If I am correct indeed I would like Firebase team to adress this issue and perhaps think of better solution, possibly create delayed notifications in the cloud.

@PatilShreyas
Copy link
Owner

Foreground service will also not work once it's removed or swiped out. Right?

@PatilShreyas
Copy link
Owner

PatilShreyas commented Jun 13, 2020

Screenshot_2020-06-13-08-26-19-584_com miui securitycenter
Here's Autostart permission and turn off batter saving.

@wellbranding
Copy link
Author

wellbranding commented Jun 13, 2020

Yes, foreground service will not work if user disables it. Thanks, I think we are getting closer! However, I can't find this exact menu like in the screenshot on Nexus 6P (API 29). I long press on application and then press App Info, and advanced.
How did you find this menu or is it Xiaomi specific ?

I checked on my Xioami MI A2 (API 29, Android P) and could not find this menu.
Screenshot_20200613-184320

@PatilShreyas
Copy link
Owner

PatilShreyas commented Jun 13, 2020 via email

@wellbranding
Copy link
Author

wellbranding commented Jun 13, 2020

I updated my question with Xiaomi MI A2 screenshot. However it is stock android, so it does not use MIU... Still it does not work on Stock android as well as NEXUS 6P. You can test yourself :)

@wellbranding
Copy link
Author

wellbranding commented Jun 13, 2020

I found exact issue on Reddit.
Seems that the only solution as I said is Foreground service, which is a hack and could be disabled...

@PatilShreyas
Copy link
Owner

PatilShreyas commented Jun 13, 2020 via email

@wellbranding
Copy link
Author

@PatilShreyas Any news? This is critical for our implementation. I have checked and OneSignal offers solution with scheduled notifications. Is there alternative with FCM without any hacky solution? :)

@PatilShreyas
Copy link
Owner

PatilShreyas commented Jun 17, 2020

Yes. You can use Firebase Cloud Function with Cron jobs which will automatically execute on specified time and date (or periodic) which will send FCM message.

See resources below:

@wellbranding
Copy link
Author

Thanks, I looked at them. They seem more like a cron job for period requests. Can I declare specific date for creating a notification? If yes, what should I pass as parameter in functions.pubsub.schedule()?

Also, if I need to create 3 notifications at random dates every day, I would need to create a 3 different pub sub requests?

@PatilShreyas
Copy link
Owner

I personally didn't try it so can't give you a satisfactory solution. I think you should ask a question on StackOverflow or write a tweet by tagging Firebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants