Keeping alive a packet tunnel provider while phone is locked

We are working on an app which includes a packet tunnel provider extension. The packet tunnel provider works by relaying traffic from a device on the same Wi-Fi network to a remote server via the iPhone's cell socket.

As such, it is important for the VPN (and the Wi-Fi connection) to remain running while the phone is locked. We have however noticed that when we lock the phone, the VPN stops running a few seconds later and will remain inactive until the phone's screen wakes up. We have set disconnectOnSleep to false but the issue still remains.

Is there a way to keep the VPN alive while the phone is locked?

Is there a way to keep the VPN alive while the phone is locked?

100%, no. I would advise that you look into the provider methods for sleepWithCompletionHandler and wake. The sleep handler will be hit when the device does into the sleep state and this would be the time to save any existing state needed to bring your tunnel back up when the wake handler is hit when your device goes through the wake cycle.

Matt Eaton - Networking

Keeping alive a packet tunnel provider while phone is locked
 
 
Q