-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
26 lines (23 loc) · 899 Bytes
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import React from 'react'
import {App} from './src/App'
import {TaskManager} from 'expo'
import {AsyncStorage} from 'react-native'
import {
ASYNC_STORAGE_GEOFENCE_KEY,
ASYNC_STORAGE_KEY,
BACKGROUND_LOCATION_TASK_NAME,
GEOFENCE_TASK_NAME,
} from './src/contants/constants'
TaskManager.defineTask(BACKGROUND_LOCATION_TASK_NAME, async ({data, error}) => {
const store = await AsyncStorage.getItem(ASYNC_STORAGE_KEY)
const events = store ? JSON.parse(store) : []
events.push(error || data)
await AsyncStorage.setItem(ASYNC_STORAGE_KEY, JSON.stringify(events))
})
TaskManager.defineTask(GEOFENCE_TASK_NAME, async ({data, error}) => {
const store = await AsyncStorage.getItem(ASYNC_STORAGE_GEOFENCE_KEY)
const events = store ? JSON.parse(store) : []
events.push(error || data)
await AsyncStorage.setItem(ASYNC_STORAGE_GEOFENCE_KEY, JSON.stringify(events))
})
export default App