Core Bluetooth and backgrounding: Detection of a device and triggering an action, even after being days in background mode?

后端 未结 3 1357
猫巷女王i
猫巷女王i 2021-01-30 02:38

I\'ve written an app that needs to get informed when a certain Bluetooth Low Energy device comes within range. If the BLE device gets noticed my app just stores a timestamp.

3条回答
  •  清酒与你
    2021-01-30 03:19

    Use IOS7 BLE State Preservation & Restoration

    If your app is terminated by IOS, due to memory pressure(this is why your app can't work after days), it can't handle bluetooth delegates anymore. In this case, if you used State Preservation & Restoration, your app can be relaunched to background to run again, also for only 10s. After 10s, it would move to suspended state. Only in this situation, CBCentralManager's willRestoreState can be triggered.

    Good luck.

提交回复
热议问题