【发布时间】:2021-12-18 20:03:37
【问题描述】:
我有一个 React-Native/Expo 托管工作流应用程序,当应用程序在后台运行时,我需要在其中跟踪用户的位置。
我已成功请求并接收到用户的前台位置,但在用户请求其后台位置权限的下一页我收到以下警告:
[Unhandled promise rejection: Error: One of the NSLocation*UsageDescription keys must be present in Info.plist to be able to use geolocation]
这是请求“背景位置”的代码的 sn-p
async function getBackgroundLocationAsync() {
let { status } = await Location.requestBackgroundPermissionsAsync()
if(status !=='granted'){
setErrorMsg('Permission to access background location was denied')
return;
}
let backgroundLocation = await Location.getBackgroundPositionAsync({});
setBackgroundLocation(backgroundLocation);
}
getBackgroundLocationAsync()
【问题讨论】:
标签: javascript react-native geolocation expo location