forked from transistorsoft/rn-background-geolocation-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.android.js
81 lines (67 loc) · 1.87 KB
/
index.android.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
'use strict';
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
View,
TouchableHighlight,
StatusBar,
Text,
PermissionsAndroid
} from 'react-native';
import Icon from 'react-native-vector-icons/Ionicons';
import BackgroundGeolocation from 'react-native-background-geolocation';
//import BackgroundGeolocationHeadlessService from './components/lib/BackgroundGeolocationHeadlessService';
async function requestLocationPermission() {
try {
const granted = await PermissionsAndroid.requestPermission(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION);
if (granted) {
console.log("You can location")
} else {
console.log("Location permission denied")
}
} catch (err) {
console.warn(err)
}
}
global.BackgroundGeolocation = BackgroundGeolocation;
import HomeView from './components/HomeView';
export default class Application extends Component {
render() {
return (
<HomeView />
);
}
}
var styles = StyleSheet.create({
});
const BackgroundGeolocationHeadlessService = async (event) => {
// do stuff
console.log('[js] BackgroundGeolocationHeadlessService: ', event);
switch (event.name) {
case 'boot':
break;
case 'terminate':
break;
case 'heartbeat':
break;
case 'motionchange':
break;
case 'location':
break;
case 'geofence':
break;
case 'http':
break;
case 'schedule':
break;
case 'activitychange':
break;
case 'providerchange':
break;
case 'geofenceschange':
break;
}
};
AppRegistry.registerHeadlessTask('BackgroundGeolocation', () => BackgroundGeolocationHeadlessService);
AppRegistry.registerComponent('RNBackgroundGeolocationSample', () => Application);