I am creating an app with cordova. I have no problems in using most plugins, only those to which I have to access through the object cordova.plugins
.
For example, when I install cordova.plugins.diagnostics or cordova-plugin-request-location-accuracy , when trying to access them using the object cordova.plugins.locationAccuracy
returns me undefined
, that is, the locationAccuracy property does not exist. The same thing happens with diagnostics, and any other plugin that needs to be accessed in this way.
I have tried to delete and reinstall platforms and plugins and nothing. I've been with this problem for several days and I can not find any solution.
I leave you the repository of the app, and the xml:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.amigos.geoapp" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>HelloCordova</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="[email protected]" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<access origin="http://192.168.0.30:3000/" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<gap:plugin name="org.apache.cordova.contacts" />
<engine name="android" spec="^7.0.0" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
<plugin name="cordova-plugin-geolocation" spec="^4.0.1" />
<plugin name="cordova-plugin-camera" spec="^4.0.1" />
<plugin name="cordova-plugin-dialogs" spec="^2.0.1" />
<plugin name="cordova-plugin-console" spec="^1.1.0" />
<plugin name="cordova.plugins.diagnostic" spec="^3.9.2" />
</widget>
[EDIT]
I am using my cell phone (samsung galaxy s5) to try the app, and I am using the phonegap console.
This is the (simplified) code that I use to check the plugins with diagnostics already installed:
document.addEventListener("deviceready", foo, false);
function foo () {
console.log(JSON.stringify(cordova.plugins));
console.log(typeof(cordova.plugins.diagnostics) === 'undefined');
}
the result:
{"screenorientation":{},"barcodeScanner":{"Encode":{"TEXT_TYPE":"TEXT_TYPE","EMAIL_TYPE":"EMAIL_TYPE","PHONE_TYPE":"PHONE_TYPE","SMS_TYPE":"SMS_TYPE"},"format":{"all_1D":61918,"aztec":1,"codabar":2,"code_128":16,"code_39":4,"code_93":8,"data_MATRIX":32,"ean_13":128,"ean_8":64,"itf":256,"maxicode":512,"msi":131072,"pdf_417":1024,"plessey":262144,"qr_CODE":2048,"rss_14":4096,"rss_EXPANDED":8192,"upc_A":16384,"upc_E":32768,"upc_EAN_EXTENSION":65536}}}
true
This is the list of plugins at the time I ran this example:
- cordova-plugin-camera 4.0.1 "Camera"
- cordova-plugin-dialogs 2.0.1 "Notification"
- cordova-plugin-geolocation 4.0.1 "Geolocation"
- cordova-plugin-whitelist 1.3.3 "Whitelist"
- cordova.plugins.diagnostic 3.9.2 "Diagnostic"