christocracy / cordova-plugin-background-geolocation

Sophisticated, battery-conscious, cross-platform background-geolocation with motion-detection
http://transistorsoft.github.io/cordova-background-geolocation
492 stars 744 forks source link

Is there a way to detect user permissions? #234

Closed garrettlangley closed 8 years ago

garrettlangley commented 9 years ago

For instance, we want to have a message if the user has either disabled or only enabled location "while in use" vs "always" as is needed for background location.

Thanks

devteamshippeo commented 9 years ago

I find this one https://www.npmjs.com/package/cordova.plugins.diagnostic

I don't test but maybe it can help you. keep me updated here if it's work for you ! Thanks

garrettlangley commented 9 years ago

this looks close @devteamshippeo

i am thinking about extending this plugin to return what type of location settings as now iOS has 3 states: https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/doc/c_ref/CLAuthorizationStatus

will let you know

devteamshippeo commented 9 years ago

@garrettlangley I finally use this plugin https://www.npmjs.com/package/cordova.plugins.diagnosticlocation

It's a forked version of the first one, it is focused on Location permissions only I made an issue and finally a PR on it because PGB cannot build it on iOS platform. https://github.com/ocean89/cordova-diagnostic-plugin/issues/2 https://github.com/ocean89/cordova-diagnostic-plugin/pull/3

I'm waiting now a response from the owner of this repository

devteamshippeo commented 9 years ago

@garrettlangley I finally do it

In my app, I need to check if location settings is set to Always (kCLAuthorizationStatusAuthorizedAlways)

So I make a really simple modification to the original plugin to check this and only this https://github.com/devteamshippeo/cordova-diagnostic-plugin/commit/348b50197c5ef44fd05beb05c5f4cf62f8fdb77b#diff-d69bee3016568bb39e512cbd1fd00606

my new npmjs repository https://www.npmjs.com/package/cordova.plugins.diagnosticlocation-shippeo

It will be nice to have dedicated methods but at this point it's ok for my needs.