Terminated App not wakeup with iBeacon packet

被刻印的时光 ゝ 提交于 2019-12-11 05:29:59

问题


Can iOS receive iBeacon packet in sleep state and wake up the app?

I killed an app and restarted, then kept the phone in sleep mode. The device was was in beacon region when device reboot and I kept the device screen off after reboot. My iOS app is not waking, so I suspect its not receiving iBeacon packet.

I checked the system log and found that the didEnterRegion procedure is not getting called.

Does app wakeup works incase of force terminated app and does iOS receive iBeacon packet in reboot and immediate sleep state?

If I make screen on then it starts working immediately but if screen is off after reboot its not receiving iBeacon packet.


回答1:


Yes, iOS CoreLocation will launch your app on region entry or region exit, and works even after force termination after iOS 7.1.1. You will only get the appropriate callback if you set up your CLLocationManagerDelegate in the AppDelegate's didFinishLaunchingWithOptions method. If you do not set this up in that method, then CoreLocation will not know to make the callback after app launch.

Testing entry events across an app restart can be a little tricky, so here are a few tips to avoid pitfalls:

  1. If is critical that your app think that it is "outside" the region when it was last running. If it was "inside" the region when it was last running, it won't necessarily get another entry callback because it will think it never left. When testing, make absolutely sure you get a didExit callback or a didDetermineState callback that says it is out of region before you kill the app or reboot. Verify this with a NSLog statement, a local notification, or some custom UI indicator added to a screen of your app.

  2. If you reboot an iOS device, CoreLocation is not fully initialized right away -- I have seen it take 5 minutes after the screen comes on before I get any callbacks. Be sure you wait long enough.

  3. Once CoreLocation is fully initialized, region entry events typically happen within one second of when the beacon comes into range. However, if the limited bluetooth hardware assist pattern slots are all full on the device (typically this happens if you have a few other beacon apps that have used them all), then entry events fall back to software scans that happen only every 10 minutes or more. An entry event can take that long in such a situation. Make sure you wait long enough before assuming it isn't working.



来源:https://stackoverflow.com/questions/51811297/terminated-app-not-wakeup-with-ibeacon-packet

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!