title: iOS background task detect screen is on or off
body: <p>I am developing an app that logs down the screen on/off events. It's a kind of smartphone usage analysis app. All the app does is to write down a log like this:</p>
  
  <pre><code>2015 July 25 at 03:54:12 PM - Screen on
  2015 July 25 at 03:59:38 PM - Screen off
  2015 July 25 at 04:20:52 PM - Screen on
  2015 July 25 at 04:22:32 PM - Screen off
  ...
  2015 July 26 at 10:20:32 AM - Screen on
  2015 July 26 at 10:22:11 AM - Screen off
  2015 July 26 at 11:30:38 AM - Screen on
  2015 July 26 at 10:31:02 AM - Screen off
  ...
  </code></pre>
  
  <ul>
  <li>"Screen on": user press home button (or power button) and enter passcode/unlock password if there is any.</li>
  <li>"Screen off": user press power button  to turn off the screen.</li>
  </ul>
  
  <p>I was able to find some way to do this this on Android using the broadcast receiver to capture the events sent by the system. But in iOS there seems to be a problem since iOS only allows background services to run several minutes, I am not even sure if I can detect the "screen on/off" event on iOS.</p>
  
  <p>I did some researches on this and found some articles, but those weren't help much:</p>
  
  <ul>
  <li><a href="http://www.macworld.com/article/1164616/how_ios_multitasking_really_works.html" rel="nofollow noreferrer">http://www.macworld.com/article/1164616/how_ios_multitasking_really_works.html</a></li>
  <li><a href="https://stackoverflow.com/questions/706344/lock-unlock-events-iphone">Lock Unlock events iphone</a></li>
  </ul>
  
  <p>My question is "<strong>Is it possible to make an app like this in iOS (latest version - 8.4) ?</strong>"</p>
  
  <p>Thanks.</p>