title: iOS10 Today Widget - how to determine if iPhone is locked or not?
body: <p>I'm adding a widget to my existing iOS App. Last week iOS10 was released and added some new features to App Extensions and so to Today Widgets.</p>
  
  <p>There are a few widgets from Apple, e.g. the "Activity widget" if you are using an Apple Watch to display your activity in the widget view. This widget is only working if your iPhone is unlocked. If it's locked it displays a message like "Unlock to show activity data" or something like that. How can I check if the user's phone is locked or not?</p>
  
  <p>I want to display some information from HealthKit and this is not possible as long as the iPhone is locked, because Apple restricts access to health data in that case. If I unlock my iPhone everything works as expected. If I'm on the lock screen it doesn't update because access is restricted.</p>
  
  <p>Apple's documentation to today widgets is pretty nice, but I couldn't find anything according to my problem.</p>
  
  <p>Here's what the widget looks like when the iPhone is locked:</p>
  
  <p><a href="https://i.stack.imgur.com/ICijC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ICijC.png" alt="enter image description here"></a></p>
  
  <p>And here's what the widget looks like when the iPhone is <strong>un</strong>locked:</p>
  
  <p><a href="https://i.stack.imgur.com/QLvI2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QLvI2.png" alt="enter image description here"></a></p>