Skip to content

Commit

Permalink
add stationary location logging and savelocation in backgroundtask (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
tremblerz committed Mar 16, 2020
1 parent c30f8eb commit 45fc937
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app/services/LocationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,13 @@ export default class LocationServices {
"time": 1583696413000
}
*/
saveLocation(location)

// to perform long running operation on iOS
// you need to create background task
BackgroundGeolocation.startTask(taskKey => {
// execute long running task
// eg. ajax post location
// IMPORTANT: task has to be ended by endTask
saveLocation(location);
BackgroundGeolocation.endTask(taskKey);
});
});
Expand All @@ -121,6 +120,13 @@ export default class LocationServices {
BackgroundGeolocation.on('stationary', (stationaryLocation) => {
// handle stationary locations here
// Actions.sendLocation(stationaryLocation);
BackgroundGeolocation.startTask(taskKey => {
// execute long running task
// eg. ajax post location
// IMPORTANT: task has to be ended by endTask
saveLocation(location);
BackgroundGeolocation.endTask(taskKey);
});
console.log('[INFO] stationaryLocation:', stationaryLocation);
});

Expand Down Expand Up @@ -216,4 +222,4 @@ export default class LocationServices {
nav.navigate('WelcomeScreen', {})
)
}
}
}

0 comments on commit 45fc937

Please sign in to comment.