Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Bluetooth background mode

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?

like image 220
huggie Avatar asked Dec 06 '15 12:12

huggie


People also ask

What is background Bluetooth?

The bluetooth-central Background Execution Mode plist file, the Core Bluetooth framework allows your app to run in the background to perform certain Bluetooth-related tasks. While your app is in the background you can still discover and connect to peripherals, and explore and interact with peripheral data.

Can iOS app run in background?

iOS puts strict limits on background execution. Its default behaviour is to suspend your app shortly after the user has moved it to the background; this suspension prevents the process from running any code. There's no general-purpose mechanism for: Running code continuously in the background.

What is background mode in iOS?

iOS restricts the use of background operations to improve user experience and extend battery life. Your app can run in the background for specific use cases, including: playing audio, updating location and fetching the latest content from a server.

What is UIBackgroundModes?

The UIBackgroundModes key identifies which background tasks your application supports. Its value is an array that contains one or more strings with the following values: audio – The application plays audible content to the user while in the background.


1 Answers

As per apple developer documentation technical Q&A.

Can I use an iOS device to issue iBeacon advertisements while my app is in the background? Answer: No. For an iOS device to issue iBeacon advertisements, the app requesting this functionality must be frontmost, with the screen turned on and the device unlocked.

Reference - https://developer.apple.com/ibeacon/Getting-Started-with-iBeacon.pdf

I found this article which provides some details to connect BLE in background for some specific case. https://medium.com/@cbartel/ios-scan-and-connect-to-a-ble-peripheral-in-the-background-731f960d520d

like image 159
Dhruv Narayan Singh Avatar answered Sep 21 '22 01:09

Dhruv Narayan Singh