3

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
4

1 回答 1

0

不在查看设备日志下——您将在此处查看故障转储。

Xcode > Window > Devices > Your Device 上有一个设备控制台。它可能已折叠——如果是,请单击右侧窗格左下角的三角形按钮。

我在控制台日志中看到以下内容:

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

然后十秒后:

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
于 2015-11-14T20:12:22.977 回答