ios 打开app应用权限
var cllocationManger = plus.ios.importClass("CLLocationManager");
var enable = cllocationManger.locationServicesEnabled();
var status = cllocationManger.authorizationStatus();
console.log("enable:" + enable);
console.log("status:" + status);
if (enable && status != 2) {
console.log("手机系统的定位已经打开");
} else {
console.log("手机系统的定位没有打开");
// 定位没有开启时 提示用户是否开启
plus.nativeUI.confirm("定位权限没有开启,是否去开启?", function(e) {
if (e.index == 0) {
var UIApplication = plus.ios.importClass("UIApplication");
var application2 = UIApplication.sharedApplication();
var NSURL2 = plus.ios.importClass("NSURL");
var setting2 = NSURL2.URLWithString("app-settings:"); // 打开应用权限
application2.openURL(setting2);
plus.ios.deleteObject(setting2);
plus.ios.deleteObject(NSURL2);
plus.ios.deleteObject(application2);
}
}, {
"buttons": ["不开启", "去设置"],
"verticalAlign": "center"
});
}
plus.ios.deleteObject(cllocationManger);
0 个评论
要回复文章请先登录或注册
李某人
jwy