How to find out if the device is locked in the Today Widget?

Number:rdar://37307307 Date Originated:07/02/2018
Status:Open Resolved:
Product:iOS Product Version:11
Classification:enhancement request Reproducible:
Lock Screen

I want to detect the locked/unlocked screen status when the Today Widget appears.

I know about the isProtectedDataAvailable property of UIApplication, but I don't have direct access to UIApplication in context of the Today Widget. I know there are the notifications (UIApplicationProtectedDataWillBecomeUnavailable and UIApplicationProtectedDataDidBecomeAvailable), but first I need to know the initial state when my Today Widget appears. For example "Find Friends" widget does this (I guess it's for security reasons), but it's made by Apple so perhaps it uses some private APIs. Say we have a smart home solution and we want to remotely disarm the alarm or even open the door from the widget - it would be a serious problem if such functionality is available on the locked screen without passcode check, while on the other hand it's very useful if the phone is unlocked. How should we do it?

I have already searched the forums and asked the question in this thread:


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!