HaylLtd / cordova-background-geolocation-plugin

Background and foreground geolocation plugin for Cordova.
Apache License 2.0
57 stars 66 forks source link

Can't start Foreground Services when the app is in Background on android 12+ #166

Closed MazahirA closed 1 year ago

MazahirA commented 1 year ago

I'm trying to start and use the Background service of the plugin on android 12+. The plugin starts foreground services before starting the background service. But because of Android's recent policies we can't start Foreground services when the app is in background on android 12+. Now I want to start only the Background service and disable Foreground for android>=12, when the app is in background. Is it possible, and how can we achieve it?

HarelM commented 1 year ago

You can set startForeground to false, but I'm not sure it will help as the OS will probably kill it. I would suggest against starting the service when the app is in the background, but instead start it when it is in the foreground.

MazahirA commented 1 year ago

It's working well in foreground. But I need to start it in background as well, it's the requirement of my app. Is there any possible fixes ?

HarelM commented 1 year ago

IDK, you'll have to dig into the code I guess...

MazahirA commented 1 year ago

Alright. Thank you for the time.