Browse Source

上传定位权限检测错误

newdev_shunjiawei
liwei1dao 1 year ago
parent
commit
8246400db7
  1. 14
      local_plugins/location_service/android/src/main/kotlin/com/yunqiinnovation/location_service/LocationService.kt

14
local_plugins/location_service/android/src/main/kotlin/com/yunqiinnovation/location_service/LocationService.kt

@ -270,13 +270,19 @@ object LocationService {
if (!hasForegroundPermission) { if (!hasForegroundPermission) {
return 1 // 前台权限未授予 return 1 // 前台权限未授予
} }
// 前台权限已授予,再根据前后台状态检查后台权限 // 前台权限已授予,再根据前后台状态检查后台权限
if (!isAppInForeground(context)) { if (!isAppInForeground(context)) {
// 应用在后台:Android 10+ 需要检查后台权限 // 应用在后台:Android 10+ 需要检查后台权限的实际授予状态
return 2 // 后台权限未授予 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
val hasBackgroundPermission = hasBackgroundLocationPermission(context)
if (!hasBackgroundPermission) {
return 2 // 后台权限未授予
}
}
// Android 9 及以下或已授予后台权限
} }
// 所有所需权限均已授予 // 所有所需权限均已授予
return 0 return 0
} }

Loading…
Cancel
Save