-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
33 lines (29 loc) · 983 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
27
28
29
30
31
32
33
import { Navigation } from "react-native-navigation";
import { registerScreens } from "./src/navigation/screens";
import BackgroundFetch from "react-native-background-fetch";
const MyHeadlessTask = async () => {
console.log("[BackgroundFetch HeadlessTask] start");
try {
var response = await fetch(
"https://facebook.github.io/react-native/movies.json"
);
var responseJson = await response.json();
console.log("[BackgroundFetch HeadlessTask] response: ", responseJson);
console.log("[BackgroundFetch HeadlessTask] Finished;");
BackgroundFetch.finish(BackgroundFetch.FETCH_RESULT_NEW_DATA);
} catch {
console.log("Catching Error");
BackgroundFetch.finish(BackgroundFetch.FETCH_RESULT_FAILED);
}
};
BackgroundFetch.registerHeadlessTask(MyHeadlessTask);
registerScreens();
Navigation.events().registerAppLaunchedListener(() => {
Navigation.setRoot({
root: {
component: {
name: "Initializing"
}
}
});
});