診断プラグインを使用して、場所がオンになっているかどうかについての情報を取得しています。プラグインは、コードのいくつかの問題のために削除するまで正常に動作していました。Cordova診断プラグインが動作しない
今、同じアプリでプラグインをもう一度追加しても、機能しません。
デモ用に作成した別のアプリで同じプラグインが動作しています。
診断プラグインのレガシーバージョンも試しました。私config.xmlの
function checkLocationEnabled(){
cordova.plugins.diagnostic.isLocationEnabled(function(enabled){
alert("Location is " + (enabled ? "enabled" : "disabled"));
alert(enabled);
if(enabled == false){
cordova.plugins.locationAccuracy.canRequest(function(canRequest){
if(canRequest){
cordova.plugins.locationAccuracy.request(function(){
alert("GPS turned on");
setLatitudeLongitude();
}, function (error){
alert("Request failed");
if(error){
// Android only
alert("error code="+error.code+"; error message="+error.message);
if(error.code !== cordova.plugins.locationAccuracy.ERROR_USER_DISAGREED){
if(window.confirm("Failed to automatically set Location Mode to 'High Accuracy'. Would you like to switch to the Location Settings page and do this manually?")){
cordova.plugins.diagnostic.switchToLocationSettings();
}
}
}
}, cordova.plugins.locationAccuracy.REQUEST_PRIORITY_HIGH_ACCURACY // iOS will ignore this
);
}
});
} else if (enabled == true){
setLatitudeLongitude();
}
}, function(error){
alert("The following error occurred: "+error);
});
}
エントリファイル
<plugin name="cordova.plugins.diagnostic" spec="~3.6.5" />
コルドバのバージョン:6.5.0
インストールプラットフォーム: アンドロイド6.2.3 ブラウザ4.1.0 ios 4.3.1
<preference name="android-minSdkVersion" value="14" />
クロムでデバッグしようとしましたが、「未定義のプロパティ診断を読み取れません」というエラーが表示されます。
また、私はWindows 7を使用しており、Android 5,5.1,6.0の異なるバージョンで同じアプリをテストしました。 (サムスン+ソニー)
以前は動作していたし、「場所が有効/無効」というアラートを表示していました。
「それは機能していません」より具体的にする必要があります。期待される行動と実際の行動を説明してください。テスト環境の詳細を入力します。 Android 7.1.1を実行している端末。 JSエラーまたはエラーメッセージが生成されている場合は、投稿してください:Chrome Dev ToolsをWebviewに接続して、JSエラーを表示し、ブレークポイントをコード内に配置してステップスルーをデバッグしてください。 – DaveAlden
@DaveAlden done –