【发布时间】:2017-07-07 14:34:39
【问题描述】:
我想强制用户在 ionic2 应用程序中打开 GPS,为此我正在使用 dpa99c/cordova-plugin-request-location-accuracy
我已经安装了这个插件,但是为什么它说插件没有安装。
如果应用程序加载此 onLocate 函数将触发并检查 GPS 是否打开,我将尝试执行此功能,如果未打开,则会提示打开 GPS,请参阅此图像
但是如果用户点击取消按钮,我想重新运行此功能并再次提示要求用户打开 GPS,如上图所示,直到用户点击确定以启动 GPS,然后我想重新加载窗口以使用 GPS 获取用户位置。
我错了
onLoacte(){
this.locationAccuracy.canRequest().then((canRequest: boolean) => {
if(canRequest) {
// the accuracy option will be ignored by iOS
this.locationAccuracy.request(this.locationAccuracy.REQUEST_PRIORITY_HIGH_ACCURACY).then(
() => console.log('Request successful'),
error => location.reload(),
);
}
});
}
【问题讨论】: