PacketTunnelProvider never calling sleepWithCompletionHandler

I'm trying to override the sleepWithCompletionHandler function on my PacketTunnelProvider, but it seems like the event is never raised.


My implementation is very simple,


- (void) sleepWithCompletionHandler:(void (^)(void))completionHandler {
    NSLog(@"Now sleeping...");
    completionHandler();
}


However I can never get that NSLog to output in the device log. I'd imagine that this function would be called when the device is locked, but it never seems to.


What am I missing here?

Replies

There’s a difference between screen lock and device sleep. Device sleep only kicks in if the screen is locked and there’s nothing else on the system keeping the device awake. One of the things that will keep the device awake is an active debugging connection. Even if you’re not debugging, it’s like that the monitoring the console log over USB will also keep the device awake. You need to test this with the device untethered.

You can use the sysdiagnose mechanism (described on our Profiles and Logs page) to capture logging that happened while the device was untethered.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"