Zunächst ich leeres Projekt erstellt mitReference: cordova nicht ionische definiert
ionic start checkGPS blank
Danach i-Plugin installiert -
cordova.plugins.diagnostic
Ich habe in www folgenden Code/index.html
cordova.plugins.diagnostic.isGpsLocationEnabled(function(enabled){
console.log("GPS location is " + (enabled ? "enabled" : "disabled"));
}, function(error){
console.error("The following error occurred: "+error);
})
Suchen in der config.xml & package.json Plugin Informationen sind bereits vorhanden y hinzugefügt, auch ich habe versucht, cordova.js
zu addieren Aber es hat nicht funktioniert, obwohl!
Index.HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title>
<link rel="manifest" href="manifest.json">
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="cordova.js"></script>
<script src="js/app.js"></script>
<script type="text/javascript">
document.addEventListener("deviceready", function() {
cordova.plugins.diagnostic.isGpsLocationEnabled(function(enabled){
console.log("GPS location is " + (enabled ? "enabled" : "disabled"));
alert('hello');
}, function(error){
console.error("The following error occurred: "+error);
})
}, false);
</script>
</head>
<body ng-app="starter">
<ion-pane>
<ion-header-bar class="bar-stable">
<h1 class="title">Ionic Blank Starter</h1>
</ion-header-bar>
<ion-content>
</ion-content>
</ion-pane>
</body>
</html>
Ja, ich hinzugefügt ... –
Sie sind sicher, dass nicht bekommt einen 404-Fehler in der Zeile ' '? Bitte überprüfen Sie Ihre App und überprüfen Sie die Konsolenausgabe. –
Testen Sie in einem Browser oder in einem echten Gerät? –