cordova-plugin-background-geolocation icon indicating copy to clipboard operation
cordova-plugin-background-geolocation copied to clipboard

Possible to only request foreground mode on IOS?

Open JonesWest opened this issue 4 years ago • 3 comments

Hi,

We're using this plugin to track workouts (cycling, running, walking). Therefore we don't need actual background tracking. On IOS it works great with the app being in "semi foregound" (I don't know what it is actually called?), where the blue location notification is shown in upper left corner of the phone, when the app itself isn't shown on screen.

So my question is, how can I make sure that foreground permissions is always what's requested? We've found that if the user selects "Allow once", it does exactly what we want - this apparently results in the AUTHORIZED_FOREGROUND. But when user selects "Allow while using" we get the AUTHORIZED and this doesn't work when the screen is turned off (before the user accepted the extra popup that appears when the phone is unlocked next time). I assume this is because the plugin tries to do "actual background location" (without the blue notification), but we don't need that.

So how can I make sure that I always get the "semi foreground" on IOS?

JonesWest avatar Apr 05 '20 11:04 JonesWest

I have found a temporary solution.

I use this plugin: https://github.com/dpa99c/cordova-diagnostic-plugin to ask for WHILE_USING permissions only, before starting the this location plugin. Then the location plugin will automatically start foreground tracking (with the blue location notification), no matter if the user selects "Allow once" or "Allow while using".

But still looking for a more elegant solution..

JonesWest avatar Apr 05 '20 13:04 JonesWest

yes, we are also looking for that type, so have you found any solution.

Thanks

ipehimanshu avatar Aug 17 '20 15:08 ipehimanshu

@JonasWestAlro Thank you! This solved my problem. Using the 'requestLocationAuthorization' method on the cordova-diagnostic-plugin enabled the blue location notification to appear on ios to get locations in the background. I think this would solve a lot of tickets on this github.

betagole avatar Sep 10 '20 17:09 betagole