Siyah
Siyah

Reputation: 2897

Ionic diagnostic plugin error when building with Xcode

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).

Upvotes: 1

Views: 766

Answers (1)

DaveAlden
DaveAlden

Reputation: 30366

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.

Upvotes: 1

Related Questions