1
Error: undefined is not an object (evaluating 'cordova.plugins.diagnostic.requestLocationAuthorization')
checkLocationSettings@file:///var/containers/Bundle/Application/17-714B2421w-12AD-A13E-17245G12B039/MyApp.app/www/js/app.js:264:35

I checked the installed plugins and I can see that I have this installed: cordova.plugins.diagnostic 3.6.5 "Diagnostic" when I do cordova plugin ls

An in my config.xml file, I have this:

<plugin name="cordova.plugins.diagnostic" spec="~3.6.5"/>

So I'd expect it would work, but it doesn't. I am trying to get it to work for the iPhone 7 (physical device, not the simulator).

0

1 Answer 1

1

An in my index.html file, I have this:

<plugin name="cordova.plugins.diagnostic" spec="~3.6.5"/>

I hope you mean config.xml not index.html.

Error: undefined is not an object (evaluating 'cordova.plugins.diagnostic.requestLocationAuthorization')

The error is indicative of the plugin either not being present in the app or being referenced before it has been dynamically loaded by Cordova.

Firstly, check the plugin is actually present in the app. You can check in XCode if the plugin files diagnostic.js and Diagnostic.m are present in your project.

Secondly, ensure you are not referencing the plugin before the deviceready event has fired, since it will not be loaded.

See the example project for a working example of the plugin.

Sign up to request clarification or add additional context in comments.

8 Comments

Hmm. So, diagnostic.js and Diagnostic.m are files I need to have? And in what folder should they be in, to be exact? I can see cordova.plugins.diagnostic in my plugins folder and also a Diagnostic.m file in the ios folder... but no diagnostic.js file. Is there a way / command I can add that one? Edit: oh yes, I've found diagnostic.js too (in www), yet I can't see them in Xcode... I only see them in my IDE.
Interesting. I have a folder called "Staging"... there, the whole diagnostic plugin is not loaded. Could that be the problem? Is that something I can fix with the ios.json file or isn't this relevant at all? I don't know what the Staging folder is and what it should do, at the moment...
In Xcode, Staging is your_project/platforms/ios/ - i.e. the native iOS project. www/ is your_project/www - i.e. the Cordova project. . There should exist Staging/www/plugins/cordova.plugins.diagnostic/www/ios/diagnostic.js and Plugins/Diagnostic.m&.h.
cordova plugin rm cordova.plugins.diagnostic; cordova plugin add cordova.plugins.diagnostic@latest; cordova prepare ios
@Siyah There's a good reason it's not in the Staging folder: it's an Android-only plugin - check the plugin.xml
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.