HaylLtd/cordova-background-geolocation-plugin

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

Closed this issue · 4 comments

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

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.

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

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

Alright. Thank you for the time.