ioslockscreendata-protectionble-state-preservation

protectedDataAvailable always true


From what I understand, UIApplication.sharedApplication().protectedDataAvailable should return false when the phone is locked and protected data is enabled on the iPhone (apparently setting a passcode enables it).

However, despite of the scenario, it always returns true.

Once my app gets reawaken by iOS due to Corebluetooth State Preservation and Restoration, I need to immediately know whether the phone is locked.

I've implemented event listeners to know when the phone gets locked/unlocked, but they are only useful once the lock state changes, I am unable to determine the lock state prior to an event.

Any ideas? Thanks

UPDATE:

this is what I use in applicationDidFinishLaunchingWithOptions:

self.phoneLockDetection.isPhoneLocked = !UIApplication.sharedApplication().protectedDataAvailable

Solution

  • Not under View Device Logs -- that's where you're going to see crash dumps.

    There's a device console on Xcode > Window > Devices > Your Device. It might be collapsed -- click the triangle button at the bottom left of the right-hand pane if so.

    I see the following in the console log:

    Nov 14 12:07:30 Ewan-Mellors-iPad SpringBoard[54] <Warning>: [MPUSystemMediaControls] Disabling lock screen media controls updates for screen turning off.
    Nov 14 12:07:30 Ewan-Mellors-iPad UserEventAgent[775] <Error>:  LockStateNotifier aksNotificationCallback posting notification: com.apple.mobile.keybagd.lock_status
    Nov 14 12:07:30 Ewan-Mellors-iPad UserEventAgent[775] <Notice>: (Note ) PIH: Lock status changed.
    Nov 14 12:07:30 Ewan-Mellors-iPad MobileMail[192] <Warning>: Key bag transitioning from unlocked to locking
    

    And then ten seconds later:

    Nov 14 12:07:40 Ewan-Mellors-iPad kernel[0] <Notice>: AppleKeyStore:Sending lock change 1 for handle 0
    Nov 14 12:07:40 Ewan-Mellors-iPad UserEventAgent[775] <Error>:  LockStateNotifier aksNotificationCallback posting notification: com.apple.mobile.keybagd.lock_status
    Nov 14 12:07:40 Ewan-Mellors-iPad UserEventAgent[775] <Notice>: (Note ) PIH: Lock status changed.
    Nov 14 12:07:40 Ewan-Mellors-iPad MobileMail[192] <Warning>: Key bag transitioning from locking to locked