forked from vitorpamplona/ble-tracker-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
26 lines (20 loc) · 856 Bytes
/
index.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
/**
* @format
*/
import { AppRegistry } from "react-native";
import App from "./App";
import { name as appName } from "./app.json";
import BackgroundFetch from "react-native-background-fetch";
import { executeTask } from "./app/services/BackgroundTaskService";
let MyHeadlessTask = async ({ taskId }) => {
console.log("[BackgroundService] Headless Task start: ", taskId);
executeTask();
console.log("[BackgroundService] Headless Task finish: ", taskId);
// Required: Signal to native code that your task is complete.
// If you don't do this, your app could be terminated and/or assigned
// battery-blame for consuming too much time in background.
BackgroundFetch.finish(taskId);
};
// Register your BackgroundFetch HeadlessTask
BackgroundFetch.registerHeadlessTask(MyHeadlessTask);
AppRegistry.registerComponent(appName, () => App);