-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
97 lines (79 loc) · 2.42 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { AppRegistry, AsyncStorage } from 'react-native'
import Axios from 'axios';
import { name as appName } from './app.json'
import App from './app/Menu.js'
import LocMan from './app/src/components/BackgroundService.js'
import {Log, Uploader, init as logInit} from './app/src/Logger.js'
import StateMan from './app/src/components/StateCheck.js'
logInit().then(() => {
Log.info('Application started');
const StateManager = new StateMan();
const Notif = async (data) => {
if(StateManager.returnState() !== 'active'){
AsyncStorage.getItem('travel', (err,res)=>{
if(res !== 'false'){
LocMan.startScan()
}
})
}
}
const initialise = async () => {
AsyncStorage.getItem(
'username', (err, res) => {
if (res == null) {
Axios.get('https://inmyseat.chronicle.horizon.ac.uk/api/v1/newuser')
.then(
response => {
AsyncStorage.setItem('username', response.data.id)
AsyncStorage.setItem('password', response.data.password)
}
)
}
}
);
AsyncStorage.getItem(
'Setting', (err, res) => {
if (res == null) {
Axios.get( "https://inmyseat.chronicle.horizon.ac.uk/api/v1/allcats" )
.then( response => {
let obj = { Direct: true, Facticle: true, Filter: response.data, NotifRate: 60 };
AsyncStorage.setItem('Setting', JSON.stringify(obj));
} )
}
}
);
AsyncStorage.getItem(
'VisPOIS', (err, res) => {
if (res == null) {
AsyncStorage.setItem('VisPOIS', JSON.stringify([]));
}
}
);
AsyncStorage.getItem(
'facticles', (err, res) => {
if (res == null) {
AsyncStorage.setItem('facticles', JSON.stringify([]));
}
}
);
AsyncStorage.getItem(
'seenFacticles', (err, res) => {
if (res == null) {
AsyncStorage.setItem('seenFacticles', JSON.stringify([]));
}
}
)
AsyncStorage.getItem(
'travel', (err, res) => {
if (res == null) {
AsyncStorage.setItem('travel', 'false');
}
})
};
initialise();
AppRegistry.registerComponent(appName, () => App)
AppRegistry.registerHeadlessTask(
'Notif',
() => Notif.bind(null, [LocMan, StateManager]));
AppRegistry.registerHeadlessTask('LogUploadTask', () => Uploader.uploadTask);
});