我正在使用诊断插件来获取有关该位置是否打开的信息。该插件工作正常,直到我删除它由于代码中的一些问题。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
安装平台: 的Android 6.2.3 浏览器4.1.0 ios 4.3.1
<preference name="android-minSdkVersion" value="14" />
试图在Chrome上进行调试,它显示未定义的错误“无法读取属性诊断”。
此外,我正在使用Windows 7,我测试了相同的应用程序在不同版本的Android 5,5.1,6.0。 (三星+索尼)
它曾用于之前的工作,并显示'位置启用/禁用'的警报。
你需要比“它不工作”更具体。描述预期与实际行为。提供测试环境的详细信息,例如运行Android 7.1.1的设备。如果生成了JS或本机错误消息,请发布它们:尝试将Chrome开发工具连接到Web视图以查看JS错误并在代码中放置断点以逐步调试它。 – DaveAlden
@DaveAlden完成那 –