(eventName)
| 32 | let doWorkCounter = 0; |
| 33 | |
| 34 | const doWork = async (eventName) => { |
| 35 | return new Promise(async (resolve, reject) => { |
| 36 | if (eventName == 'terminate') { |
| 37 | doWorkCounter = 0; |
| 38 | // Perform a weird action (for testing) with an interval timer and .startBackgroundTask. |
| 39 | const bgTaskId = await BackgroundGeolocation.startBackgroundTask(); |
| 40 | // Print * tick * to log every second. |
| 41 | const timer = setInterval(() => { |
| 42 | console.log(`[BGGeoHeadlessTask *][doWork] * tick ${++doWorkCounter}/10 *`); |
| 43 | }, 1000); |
| 44 | // After 10s, stop the interval and stop our background-task. |
| 45 | setTimeout(() => { |
| 46 | clearInterval(timer); |
| 47 | BackgroundGeolocation.stopBackgroundTask(bgTaskId); |
| 48 | resolve(); |
| 49 | }, 10000); |
| 50 | |
| 51 | } else { |
| 52 | // do nothing |
| 53 | console.log('[BGGeoHeadlessTask *][doWork]', eventName); |
| 54 | resolve(); |
| 55 | } |
| 56 | }); |
| 57 | } |
| 58 | |
| 59 | AppRegistry.registerComponent(appName, () => App); |
no test coverage detected