我希望如果用户没有在这个代码上转GPS,如果用户点击取消它就会提示转GPS,重新运行$ scope.checkGPS();并再次提示用户打开,直到用户点击确定 如果用户点击确定然后重新加载窗口,我想要的是什么 哪里我错了怎么办?
查看应用
的屏幕截图
$scope.checkGPS = function (){
console.log("GPS Ceck ran");
cordova.plugins.locationAccuracy.canRequest(function(canRequest){
if(canRequest){
cordova.plugins.locationAccuracy.request(function (success){
}, function (error){
console.error("Accuracy request failed: error code="+error.code+"; error message="+error.message);
if(error.code == 4){
console.error("while Accuracy request failed: error code="+error.code+"; error message="+error.message);
$scope.checkGPS();
}else(success.message == cordova.plugins.locationAccuracy.SUCCESS_USER_AGREED){
console.log(" User OK ");
}
// 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);
}
});
}
答案 0 :(得分:0)
您可以使用$window.location.reload();
重新加载window
if(error.code == 4){
console.error("while Accuracy request failed: error code="+error.code+"; error message="+error.message);
$scope.checkGPS();
}else(success.message == cordova.plugins.locationAccuracy.SUCCESS_USER_AGREED){
console.log(" User OK ");
$window.location.reload();
}
添加加载叠加层,隐藏所有内容 - >重定向到您的初始状态并调用$ window.location.reload();.它就像一个整页重新加载。加载图层是隐藏一些丑陋的效果,直到你的应用再次准备好
答案 1 :(得分:0)
此代码无法正常工作但在一个工作
之下感谢您的回复
if(error.code == 4){
console.error("while Accuracy request failed: error code="+error.code+"; error message="+error.message);
$scope.checkGPS();
}else if(success.message == cordova.plugins.locationAccuracy.SUCCESS_USER_AGREED){
console.log(" User OK ");
$window.location.reload();
}