-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNetworkInfo.js
49 lines (37 loc) · 1.2 KB
/
NetworkInfo.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
"use strict";
import { NativeModules, Platform, TurboModuleRegistry } from "react-native";
const NetworkInfoNativeModule = TurboModuleRegistry ? TurboModuleRegistry.get('NetworkInfoNativeModule') : NativeModules.NetworkInfoNativeModule
const NetworkInfo = {
async getSSID() {
return await NetworkInfoNativeModule.getSSID();
},
async getBSSID() {
return await NetworkInfoNativeModule.getBSSID();
},
async getBroadcast() {
return await NetworkInfoNativeModule.getBroadcast();
},
async getIPAddress() {
return await NetworkInfoNativeModule.getIPAddress();
},
async getIPV4Address() {
const wifiIP = await NetworkInfoNativeModule.getWIFIIPV4Address();
if (wifiIP && wifiIP !== '0.0.0.0') {
return wifiIP;
}
return await NetworkInfoNativeModule.getIPV4Address();
},
async getGatewayIPAddress() {
return await NetworkInfoNativeModule.getGatewayIPAddress();
},
async getSubnet() {
return await NetworkInfoNativeModule.getSubnet();
},
async getFrequency() {
if (Platform.OS === 'android' || Platform.OS === 'harmony') {
return await NetworkInfoNativeModule.getFrequency();
}
return null;
}
};
module.exports = { NetworkInfo };