-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.android.js
72 lines (56 loc) · 1.51 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
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
var React = require('react-native');
var { DeviceEventEmitter } = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
} = React;
debugger;
var ToastAndroid = React.NativeModules.ToastAndroidSai;
ToastAndroid.show('Awesome', ToastAndroid.SHORT);
var sms = React.NativeModules.SmsModule;
sms.send(
"12345678",
"Message text",
() => console.log('Message was sent!'),
(err) => console.log('Could not send message', err)
);
var RNALocation = React.NativeModules.RNALocation;
var SaiCustomModule = React.createClass({
// Create and Reset initial State Longitude (lng) and Latitude (lat)
getInitialState: function() { return { lng: 0.0, lat: 0.0}; },
componentDidMount: function() {
// Register Listener Callback !Important!
DeviceEventEmitter.addListener('updateLocation', function(e: Event) {
this.setState({lng: e.Longitude, lat: e.Latitude });
}.bind(this));
// Initialize RNALocation
RNALocation.getLocation();
},
render() {
return (
<View style={styles.container}>
<Text style={styles.location}>
Lng: {this.state.lng} Lat: {this.state.lat}
</Text>
</View>
);
}
});
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
location: {
textAlign: 'center'
}
});
AppRegistry.registerComponent('SaiCustomModule', () => SaiCustomModule);