iOS CoreBluetooth: State Preservation and Restoration

不羁的心 提交于 2019-12-03 16:05:35

Finally made some tests and got results. It turns out that the app is launched into background when needed, which means whenever the peripheral sends data on the preserved connection. iOS launches the app through didFinishLaunchingWithOptions in this case, so you have ~10 seconds to check your launch options and do something. So my problem was related to the fact that there was no data sent on the connection, seems we now have to change the firmware of our peripheral to sort this out.

The delegate willRestoreState is called when relaunching the app manually. At this point iOS provides not only the recently used central but also a list of connected peripherals and even the recently subscribed services. So I just had to restore my objects and get the subscribed characteristic from the right service of the connected peripheral to be fully functional again.

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