Created
May 18, 2018 12:12
-
-
Save GillesVercammen/ba36370b84818e3ba3191c4ea3e9c17d to your computer and use it in GitHub Desktop.
geo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_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