Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save GillesVercammen/ba36370b84818e3ba3191c4ea3e9c17d to your computer and use it in GitHub Desktop.
Save GillesVercammen/ba36370b84818e3ba3191c4ea3e9c17d to your computer and use it in GitHub Desktop.
geo
_handleAppStateChange = appState => {
console.log('in appstatechange')
const { status, manualStop } = this.state
if (appState === 'active') {
this._updatePermissions('location', 'handle')
if (status === 'authorized' && !manualStop) {
console.log('[NOTE] app is in handleAppstate and authorized, starting tracking!!!')
BackgroundGeolocation.configure({
locationProvider: BackgroundGeolocation.RAW_PROVIDER,
interval: 10000,
fastestInterval: 5000,
activitiesInterval: 10000
})
console.log('HANDLE STATE AND STARTING')
BackgroundGeolocation.stop()
BackgroundGeolocation.start()
}
}
BackgroundGeolocation.checkStatus(status => {
console.log('[INFO] BackgroundGeolocation service is running', status.isRunning)
console.log('[INFO] BackgroundGeolocation services enabled', status.locationServicesEnabled)
console.log('[INFO] BackgroundGeolocation auth status: ' + status.authorization)
// you don't need to check status before start (this is just the example)
if (status.isRunning) {
console.log('tracking')
} else {
console.log('not tracking')
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment