【发布时间】:2022-01-23 15:38:18
【问题描述】:
我正在尝试使用 expo Location 获取后台权限。这适用于 android 和 iOS 模拟器,但不适用于物理 iOS 设备。
const askLoc = async () => {
const requestForeground = await Location.requestForegroundPermissionsAsync();
if (requestForeground.status === 'granted') {
const requestBackground = await Location.requestBackgroundPermissionsAsync();
if (requestBackground.status === 'granted') {
console.log('background location granted');
}
}
};
这就是我的app.json 的样子。
"ios": {
"infoPlist": {
"NSCameraUsageDescription": "This app uses the camera to send pictures or create a new profile photo.",
"NSPhotoLibraryAddUsageDescription": "User can download documents that were previously uploaded by company",
"NSPhotoLibraryUsageDescription": "User can upload Photos/Documents to be seen by his/her company",
"NSLocationAlwaysUsageDescription": "Location is shared with users company while he/she is completing a task/job.",
"NSLocationWhenInUseUsageDescription": "Location is shared with users company while he/she is completing a task/job.",
"NSUserActivityTypes": ["INSendMessageIntent", "INStartCallIntent"],
"UIBackgroundModes": ["location", "fetch"],
"CFBundleAllowMixedLocalizations": true
}
},
【问题讨论】:
标签: ios react-native geolocation expo user-permissions