iOS Bluetooth background mode

ぃ、小莉子 提交于 2020-07-17 08:06:08

问题


I wish to keep scanning for Bluetooth Devices and I want app to be alive in the background. Is it possible? It seems like if I have a connected Bluetooth device, and if there is data transfer, then the app stays awake in the background. However, if I am just scanning in the background, it seems like even if I have Uses Bluetooth LE accessories checked(bluetooth-central in plist), the app ends up not running.

Is there a way to keep the app alive and continuous scan for devices when it is in the background?


回答1:


If your app is not going to be released on Apple Store, you can use any of the background modes explained here. Please read this whole article if you don't understand background execution in iOS - it's essential that you know this as an iOS developer.

You also seem to not understand fully how Core Bluetooth works in background so please read this article.

In short: you need a good reason to keep your app alive in background indefinitely and be accepted by Apple Store Review.

EDIT:

What OP meant is that the device doesn't get woken up. Solution: You need to listen for particular BLE service in CoreBluetooth in order go get woken up.



来源:https://stackoverflow.com/questions/34117336/ios-bluetooth-background-mode

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