I have a today extension that displays a timer. I want to pause the timer when the screen is locked, but can't figure out how to detect if the screen is locked.

I tried doing this but the file is always readable even when the screen is locked:
[Finding out if the device is locked, from a Notification Widget](https://stackoverflow.com/questions/27933666/finding-out-if-the-device-is-locked-from-a-notification-widget)

I was able to do this in my app using this but am unable to implement it in a widget:
[How can I detect screen lock/unlock events on the iPhone?](https://stackoverflow.com/questions/7888490/how-can-i-detect-screen-lock-unlock-events-on-the-iphone)