I want use BackGround Location on ios and android . on android is working but on ios its show error
[Unhandled promise rejection: Error: Background Location has not been configured. To enable it, add location
to UIBackgroundModes
in Info.plist file.]
my app.json file
“ios”: {
“bundleIdentifier”: “com.apk.witown”,
“infoPlist”: {
“NSLocationAlwaysUsageDescription”: “For a better experience, while using our Service, we may require you to provide us Location Permissions”,
“UIBackgroundModes”: [“location”, “fetch”]
}
“sdkVersion”: “33.0.0”,
background location code
await Permissions.askAsync(Permissions.LOCATION);
await Location.startLocationUpdatesAsync(LOCATION_TRACKER, {
distanceInterval:500,
});
task
if (!TaskManager.isTaskDefined(‘geofence’)) {
TaskManager.defineTask(LOCATION_TRACKER, async ({ data, error }) => {
if (error) {
console.log(error)
// Error occurred - check error.message
for more details.
return;
}
if (data) {
const { locations } = data;
}
)}
}
2 Likes
Hey @iamvijay ,
Can you share the full code relevant to the location code? It looks like you just have a snippet of your function above.
Cheers,
Adam
async fetchBackGroundLocation() {
const {status, permissions} = await Permissions.askAsync(Permissions.LOCATION);
if (status === 'granted') {
await Location.startLocationUpdatesAsync(LOCATION_TRACKER, {
accuracy: Location.Accuracy.BestForNavigation, distanceInterval:500,
});
} else {
dispatch(fetchLocationError());
throw new Error('Location permission not granted');
}
TASK
if (!TaskManager.isTaskDefined(‘geofence’)) {
TaskManager.defineTask(LOCATION_TRACKER, ({ data, error }) => {
if (error) {
console.log(error)
// Error occurred - check error.message
for more details.
return;
}
if (data) {
const { locations } = data;
console.log('latitude>>',locations[0].coords.latitude +'<<longitude>>'+locations[0].coords.longitude)
console.log('token in Task ',token)
}
})};
ichigen
September 8, 2019, 2:35am
4
I also have the same phenomenon.
My expo version: 34.0.1
system
Closed
September 23, 2019, 2:35am
5
This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.