-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeviceinfo.js
289 lines (285 loc) · 5.26 KB
/
deviceinfo.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
/**
* @providesModule react-native-device-info
*/
import { Platform, NativeModules, Dimensions } from 'react-native';
var RNDeviceInfo = NativeModules.RNDeviceInfo;
if (!RNDeviceInfo && Platform.OS === 'web') {
RNDeviceInfo = require('./web');
}
const devicesWithNotch = [
{
brand: 'Apple',
model: 'iPhone X',
},
{
brand: 'Apple',
model: 'iPhone XS',
},
{
brand: 'Apple',
model: 'iPhone XS Max',
},
{
brand: 'Apple',
model: 'iPhone XR',
},
{
brand: 'Asus',
model: 'ZenFone 5',
},
{
brand: 'Asus',
model: 'ZenFone 5z',
},
{
brand: 'google',
model: 'Pixel 3 XL',
},
{
brand: 'Huawei',
model: 'P20',
},
{
brand: 'Huawei',
model: 'P20 Plus',
},
{
brand: 'Huawei',
model: 'P20 Lite',
},
{
brand: 'Huawei',
model: 'Honor 10',
},
{
brand: 'Huawei',
model: 'Nova 3',
},
{
brand: 'Huawei',
model: 'Nova 3i',
},
{
brand: 'Leagoo',
model: 'S9',
},
{
brand: 'LG',
model: 'G7',
},
{
brand: 'LG',
model: 'G7 ThinQ',
},
{
brand: 'LG',
model: 'G7+ ThinQ',
},
{
brand: 'Nokia',
model: '6.1 Plus',
},
{
brand: 'OnePlus',
model: '6',
},
{
brand: 'OnePlus',
model: 'A6003',
},
{
brand: 'ONEPLUS',
model: 'A6000',
},
{
brand: 'OnePlus',
model: 'OnePlus A6003',
},
{
brand: 'OnePlus',
model: 'ONEPLUS A6000',
},
{
brand: 'Oppo',
model: 'R15',
},
{
brand: 'Oppo',
model: 'R15 Pro',
},
{
brand: 'Oppo',
model: 'F7',
},
{
brand: 'Oukitel',
model: 'U18',
},
{
brand: 'Sharp',
model: 'Aquos S3',
},
{
brand: 'Vivo',
model: 'V9',
},
{
brand: 'Vivo',
model: 'X21',
},
{
brand: 'Vivo',
model: 'X21 UD',
},
{
brand: 'xiaomi',
model: 'MI 8',
},
{
brand: 'xiaomi',
model: 'MI 8 Explorer Edition',
},
{
brand: 'xiaomi',
model: 'MI 8 SE',
},
{
brand: 'xiaomi',
model: 'MI 8 UD',
},
{
brand: 'xiaomi',
model: 'MI8Lite',
},
{
brand: 'xiaomi',
model: 'POCO F1',
},
{
brand: 'xiaomi',
model: 'Redmi 6 Pro',
},
];
export default {
getUniqueID: function() {
return RNDeviceInfo.uniqueId;
},
getInstanceID: function() {
return RNDeviceInfo.instanceId;
},
getSerialNumber: function() {
return RNDeviceInfo.serialNumber;
},
getIPAddress: function() {
return RNDeviceInfo.getIpAddress();
},
getMACAddress: function() {
return RNDeviceInfo.getMacAddress();
},
getDeviceId: function() {
return RNDeviceInfo.deviceId;
},
getManufacturer: function() {
return RNDeviceInfo.systemManufacturer;
},
getModel: function() {
return RNDeviceInfo.model;
},
getBrand: function() {
return RNDeviceInfo.brand;
},
getSystemName: function() {
return RNDeviceInfo.systemName;
},
getSystemVersion: function() {
return RNDeviceInfo.systemVersion;
},
getAPILevel: function() {
return RNDeviceInfo.apiLevel;
},
getBundleId: function() {
return RNDeviceInfo.bundleId;
},
getApplicationName: function() {
return RNDeviceInfo.appName;
},
getBuildNumber: function() {
return RNDeviceInfo.buildNumber;
},
getVersion: function() {
return RNDeviceInfo.appVersion;
},
getReadableVersion: function() {
return RNDeviceInfo.appVersion + '.' + RNDeviceInfo.buildNumber;
},
getDeviceName: function() {
return RNDeviceInfo.deviceName;
},
getUserAgent: function() {
return RNDeviceInfo.userAgent;
},
getDeviceLocale: function() {
return RNDeviceInfo.deviceLocale;
},
getDeviceCountry: function() {
return RNDeviceInfo.deviceCountry;
},
getTimezone: function() {
return RNDeviceInfo.timezone;
},
getFontScale: function() {
return RNDeviceInfo.fontScale;
},
isEmulator: function() {
return RNDeviceInfo.isEmulator;
},
isTablet: function() {
return RNDeviceInfo.isTablet;
},
is24Hour: function() {
return RNDeviceInfo.is24Hour;
},
isPinOrFingerprintSet: function() {
return RNDeviceInfo.isPinOrFingerprintSet;
},
hasNotch: function() {
return devicesWithNotch.findIndex(item => item.brand.toLowerCase() === RNDeviceInfo.brand.toLowerCase() && item.model.toLowerCase() === RNDeviceInfo.model.toLowerCase()) !== -1;
},
getFirstInstallTime: function() {
return RNDeviceInfo.firstInstallTime;
},
getInstallReferrer: function() {
return RNDeviceInfo.installReferrer;
},
getLastUpdateTime: function() {
return RNDeviceInfo.lastUpdateTime;
},
getPhoneNumber: function() {
return RNDeviceInfo.phoneNumber;
},
getCarrier: function() {
return RNDeviceInfo.carrier;
},
getTotalMemory: function() {
return RNDeviceInfo.totalMemory;
},
getMaxMemory: function() {
return RNDeviceInfo.maxMemory;
},
getTotalDiskCapacity: function() {
return RNDeviceInfo.totalDiskCapacity;
},
getFreeDiskStorage: function() {
return RNDeviceInfo.freeDiskStorage;
},
getBatteryLevel: function() {
return RNDeviceInfo.getBatteryLevel();
},
isLandscape: function() {
const { height, width } = Dimensions.get('window');
return width >= height;
},
isAirPlaneMode: function() {
return RNDeviceInfo.isAirPlaneMode();
}
};