Skip to main content

Check if VPN is on (device.is_vpn_on)

Declaration​

on, desc = device.is_vpn_on()

Returns​

  • on
    Boolean. true when the VPN switch is on (connecting or already connected); false otherwise.
  • desc
    String | nil. A description of the current VPN connection state when on is true.

Description​

on also returns true while the VPN is connecting (not yet established).
desc text may vary across locales and iOS versions, and is not guaranteed to be consistent.
See the VPN config module (vpnconf) for more VPN features.

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