Hi,
I'll explain my question through how whatsapp does it.
When the phone is locked then whatsapp routes call through apple's native callkit
When unlocked, pressing accept essentially redirects to whatsapp and then whatsapp handles the call from there.
However, this component of unlock detection is what I'm not able to find any info about.
Essentially,
how i do it is:
let isPhoneLocked = !UIApplication.shared.isProtectedDataAvailable isProtectedDataAvailable == true → device is unlocked isProtectedDataAvailable == false → device is locked
The problem is that if the phone has been recently unlocked, then protected data is still available on the phone even after the lock for the next 10-40 seconds. So theres a false positive.
I want there to be a foolproof and robust way to do this. And I'm not entirely sure how
It's possible that the keychain APIs might track lock state more closely
They do not.
Using the data protection state as a proxy for the device lock state is a mistake. There are numerous ways in which this can fail, with the biggest one being that it’s a complete non-starter if the user doesn’t have a passcode set on their phone.
There’s no supported way to track the device lock state specifically. If you’re building a VoIP app then, as Kevin noted, CallKit is the recommended way to wrangle you’re UI. If you’re not building a VoIP app, please clarify your goals so that we can see if there are any good options. What are you actually planning to do with this information?
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"