Check if VPN is on (device.is_vpn_on)
Declaration
on, desc = device.is_vpn_on()
Returns
- on
Boolean. true if VPN switch is ON (connecting or connected); otherwise false - desc
String | nil. When the first return value is true, this returns a description of the VPN connection state
Notes
When VPN is connecting (not yet connected), on returns true
The same state description may differ between locales or iOS versions
See more VPN features in VPN config module (vpnconf)
Example
while true do
local is_on, stat = device.is_vpn_on()
if is_on then
sys.toast(stat)
else
device.turn_on_vpn()
end
end
Note: Uses function outside this chapter sys.toast