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

requestLocationAuthorization - Can't find variable: error #23

Closed
meeeu opened this issue Dec 9, 2015 · 2 comments
Closed

requestLocationAuthorization - Can't find variable: error #23

meeeu opened this issue Dec 9, 2015 · 2 comments

Comments

@meeeu
Copy link

meeeu commented Dec 9, 2015

When using requestLocationAuthorization in iOS with and without passing in "when_in_use"

cordova.plugins.diagnostic.requestLocationAuthorization(function(){
console.log("Successfully requested location authorization always");
}, function(error){
console.error(error);
}, "when_in_use");

Error in Error callbackId: Diagnostic786250294 : ReferenceError: Can't find variable: error

@dpa99c
Copy link
Owner

dpa99c commented Dec 9, 2015

I'm not able to reproduce this - requestLocationAuthorization is working fine when used in the example example project. Tested on iOS 7.0, 8.0, 9.1

So first I'd suggest to try building+running the example project to confirm that the plugin works OK in your build environment. Then I'd suggest using Safari to remote debug the WebView in your app and insert a breakpoint on the console.error(error); line to see if error is indeed undefined. If so, run the app via Xcode and see if there's any error in the Objective-C log output.

@meeeu
Copy link
Author

meeeu commented Dec 10, 2015

Figure out the problem
For iOS 8 and above, your app must have a value for NSLocationAlwaysUsageDescription in its Info.plist

Adding
NSLocationWhenInUseUsageDescription
This app will now only track your location when the screen is on and the app is displayed.
NSLocationAlwaysUsageDescription
This app requires constant access to your location in order to track your position, even when the screen is off.

fixed it

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