javascript - 如何让我的服务器在不在 React Native App 中时接收后台位置?
问题描述
我开发了一个应用程序,允许我在使用应用程序时跟踪我的用户位置,但是当我在应用程序之外导航时,我的服务器失去了跟踪我的能力,并且我断开了连接。有人告诉我使用 location.GetBackgroundPermissionAsync() 但我似乎写不正确。
下面是我编写的用于跟踪他们当前位置的代码。我将如何重写它以跟踪背景位置?
async function getLocationAsync() {
const { status, permissions } = await Permissions.askAsync(Permissions.LOCATION)
if (status === 'granted'){
return Location.getCurrentPositionAsync({ enableHighAccuracy: true });
console.log('Your location is granted')
} else {
alert('Location Permission Not Given')
}
}
getLocationAsync()