I am using Ionic 2.
I followed this, and did the following:
cordova plugin add cordova.plugins.diagnostic npm install -g typings typings install dt~cordova --save --global
app.ts
if (window.cordova && cordova.plugins) {
cordova.plugins.diagnostic.isLocationEnabled(function (enabled) {
alert("Location is " + (enabled ? "enabled" : "disabled"));
}, function (error) {
alert("The following error occurred: " + error);
});
}
}
I get the following error:
error TS2339: Property 'diagnostic' does not exist on type 'CordovaPlugins'.
I notice that window.cordova
is undefined
.
If anyone can advise how I can get the Cordova Plugin working, I would appreciate it.
Thanks
So for Ionic 2, try window['plugins'] in place of cordova.plugins.