Created
May 18, 2018 07:52
-
-
Save GillesVercammen/77a4dd2c5e9ffffb497b5128891e137a to your computer and use it in GitHub Desktop.
start service and check status
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 => { | |
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: 20000, | |
fastestInterval: 5000, | |
activitiesInterval: 10000 | |
}) | |
console.log('HANDLE STATE AND STARTING') | |
BackgroundGeolocation.stop() | |
BackgroundGeolocation.start() // THE SERVICE GETS STARTED HERE FOR FIRST TIME | |
} | |
} | |
// THIS IS RUNNING BEFORE THE SERVICE ACTUALLY STARTED | |
BackgroundGeolocation.checkStatus(({ isRunning }) => { | |
console.log('[NOTE] CHECKING THE TRACKING STATUS!!!') | |
if (isRunning) { | |
console.log('[NOTE] TRACKING IS RUNNING') | |
this.setState({ isTrackingRunning: true }) | |
} else { | |
console.log('[NOTE] TRACKING IS NOT RUNNING') | |
this.setState({ isTrackingRunning: false }) | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment