expo-vpn-checker
v0.1.4
Published
Check if VPN is enabled
Downloads
2,158
Maintainers
Readme
Expo VPN Checker
This is expo module for checking if device has an active VPN connection.
[!IMPORTANT] Expo modules still don't work in Windows enviroment. See FYI.
The API is very simple. There is only one checkVpn() method, which returns true or false, depending on the state of the device.
Setup
:white_check_mark: In app.json in the root of your project update ios section:
"ios": {
...
"entitlements": {
"com.apple.developer.networking.wifi-info": true
}
}:white_check_mark: Then run:
npx expo install expo-vpn-checker:white_check_mark: To use native module you need to make a development build
npx expo prebuildDONE!
for IOS:
npx expo run:iosfor Android:
npx expo run:androidauto import is not supported, use:
import ExpoVpnChecker from "expo-vpn-checker";Usage
import ExpoVpnChecker from "expo-vpn-checker";
import {Text} from "react-native"
export default function App() {
const [isVpnEnabled, setIsVpnEnabled] = useState(false);
useEffect(() => {
const result = ExpoVpnChecker.checkVpn();
setIsVpnEnabled(result);
}, [])
return (
<>
<Text>{isVpnEnabled.toString()}</Text>
...
</>
);
}