This repository was archived by the owner on Sep 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathApp.js
More file actions
82 lines (73 loc) · 1.66 KB
/
App.js
File metadata and controls
82 lines (73 loc) · 1.66 KB
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
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import React from 'react';
import {
StyleSheet,
View,
Text,
PermissionsAndroid,
} from 'react-native';
import RNSimData from 'react-native-sim-data'
class App extends React.Component {
state = {
data: {}
}
componentDidMount() {
this.requestPermissions()
this.getSimData()
}
getSimData() {
const data = RNSimData.getSimInfo();
const extracted = {
isNetworkRoaming0: data.isNetworkRoaming0,
mcc0: data.mcc0,
subscriptionId0: data.subscriptionId0,
simSerialNumber0: data.simSerialNumber0,
carrierName0: data.carrierName0,
isDataRoaming0: data.isDataRoaming0,
phoneNumber0: data.phoneNumber0,
mnc0: data.mnc0,
simSlotIndex0: data.simSlotIndex0,
deviceId0: data.deviceId0,
displayName0: data.displayName0,
countryCode0: data.countryCode0
}
this.setState({ extracted });
}
requestPermissions() {
PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.READ_PHONE_STATE)
}
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
data: {this.state.extracted && JSON.stringify(this.state.extracted, null, 2)}
</Text>
</View>
);
}
}
export default App;
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});