checkOpenGPSServiceByAndroid: function (callback) {
var app = this;
var result = 0;
let system = uni.getSystemInfoSync(); // 获取系统信息
if (app.globalData.isPermissionRequested) {
// 已经申请过权限,不再重复申请
return;
}
if (system.platform == 'android') {
// 判断平台
plus.android.requestPermissions(
['android.permission.ACCESS_FINE_LOCATION'],
function (resultObj) {
console.log('resultObj---', resultObj);  
                    if (resultObj.granted.length > 0) {  
                        //已获取的权限  
                        uni.setStorageSync('openGPS', 4); //4 成功 3拒绝本次  2 永久拒绝  
                        result = 1;  
                    } else if (resultObj.deniedPresent.length > 0) {  
                        //拒绝本次申请的权限  
                        uni.setStorageSync('openGPS', 3);  
                        result = 0;  
                    } else if (resultObj.deniedAlways.length > 0) {  
                        //永久拒绝申请的权限  
                        uni.setStorageSync('openGPS', 2);  
                        result = -1;  
                    }  
                    app.globalData.isPermissionRequested = true;  
                    typeof callback == 'function' && callback(result);  
                },  
                function (error) {  
                    app.globalData.isPermissionRequested = true;  
                    console.log('申请权限错误:' + error.code + ' = ' + error.message);  
                    resolve({  
                        code: error.code,  
                        message: error.message  
                    });  
                    typeof callback == 'function' && callback(result);  
                }  
            );  
        } else {  
            typeof callback == 'function' && callback(result);  
        }  
    }, 
             
             
             
			 
                                        
                                     
                                                                     
                                                                     
                                                                     
            
5***@qq.com (作者)
我在真机上调试。如果永久拒绝,把方法放在tabbar页面里面的onshow 方法里,方法一直循环执行方法
2024-01-29 09:31