ios - Proximity state not changing after receiving notification -


i having problem proximity sensor on iphone. seems when idle timer disabled , proximity monitoring enabled screen (sometimes) turn on when receiving notification. after proximity state reported incorrectly , screen won't turn off again.

i provided sample project illustrate problem. steps reproduce quite simple. tested on multiple phones (4s, 5, 6, 6+) multiple ios versions (7.0.3 , 8.3). seems occur reliably when phone not connected power source or debugger.

the code in viewcontroller (the view created in storyboard):

import uikit  class viewcontroller: uiviewcontroller {      @iboutlet weak var checkingtogglebutton: uibutton!     @iboutlet weak var debuglabel: uilabel!     @iboutlet weak var screendebuglabel: uilabel!      override func viewdidload() {         super.viewdidload()          self.checkingtogglebutton.settitle("start checking", forstate: uicontrolstate.normal)         self.debuglabel.text = "not checking"          nsnotificationcenter.defaultcenter().addobserver(self, selector: selector("proximitychanged:"), name: "uideviceproximitystatedidchangenotification", object: nil)     }      @ibaction func handlecheckingtoggle(sender: anyobject) {          let enabled = !uidevice.currentdevice().proximitymonitoringenabled         if enabled {             self.debuglabel.text = "checking"             self.checkingtogglebutton.settitle("stop checking", forstate: uicontrolstate.normal)         } else {             self.debuglabel.text = "not checking"             self.checkingtogglebutton.settitle("start checking", forstate: uicontrolstate.normal)         }         uiapplication.sharedapplication().idletimerdisabled = enabled         uidevice.currentdevice().proximitymonitoringenabled = enabled     }      func proximitychanged(notification:nsnotification)     {         if uidevice.currentdevice().proximitystate{             self.screendebuglabel.text = "proximity true"             println("proximity true")         } else {             self.screendebuglabel.text = "proximity false"             println("proximity false")         }     } } 

steps reproduce:

  1. build provided sample project on device , run app on the device disconnected power , debugger (this seems make difference).
  2. enable proximitymonitoring , disable idle timer pressing "start checking" button.
  3. cover proximity sensor, turns screen off.
  4. wait approximately 2 minutes (this makes difference, doing won't reproduce problem)
  5. send notification (for instance imessage)

the screen turn on , won't turn off again. created label shows current proximitystate, state (incorrectly) reported false.

link sample project on github: https://github.com/timpelgrim/proximitytest

i sent in technical support issue apple engineers , told me bug in operating system. no report on when gets fixed advised issue seems occur in versions of (at least) ios 7 , 8 , there not seem workaround. update here if receive notice of fix.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -