Skip to content

Instantly share code, notes, and snippets.

@christocracy
Last active May 24, 2024 15:28
Show Gist options
  • Save christocracy/516809e81b479f7b0556eb1a9277bcbd to your computer and use it in GitHub Desktop.
Save christocracy/516809e81b479f7b0556eb1a9277bcbd to your computer and use it in GitHub Desktop.
Background Geolocation Scheduler
// Listen to schedule events
BackgroundGeolocation.onSchedule((state) => {
console.log('- Schedule event, enabled:', state.enabled);
});
BackgroundGeolocation.ready({
startOnBoot: true, // Scheduler will start when device is rebooted.
stopOnTerminate: false, // Continue after app-terminate.
schedule: [
'2,4 6:00-19:00', // Mon,Wed: 6:00am-7:00pm
'3 11:00-14:00', // Tue: 11:00am-2:00pm
'6 6:00-7:00', // Fri: 6:00am-7:00am
'6 8:00-19:00', // Fri: 8:00am-7:00pm
'2-6 20:00-21:00' // Mon-Fri: 8:00pm-9:00pm
]
}, (state) => {
// Start the scheduler
BackgroundGeolocation.startSchedule();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment