1

I have an app that uses Bluetooth to connect with a Bluetooth device that gives a temperature reading. When the temperature reaches a certain level the alarm rings. It works perfectly fine in the foreground. The problem is I am not being able to get data from a device while it's in the background. Since the nature of the app is it must connect with Bluetooth devices and get data all the time. How can I run this kind of app in the background forever?

Casper Spruit
  • 944
  • 1
  • 13
  • 31
Bibek
  • 3,689
  • 3
  • 19
  • 28

1 Answers1

1

Have you requested the bluetooth-central background mode?

See the Core Bluetooth Programming Guide for more:

If your app needs to run in background to perform certain Bluetooth-related tasks, it must declare that it supports a Core Bluetooth background execution mode in its Information property list (Info.plist) file. When your app declares this, the system wakes it up from a suspended state to allow it to handle Bluetooth-related events. This support is important for apps that interact with Bluetooth low energy devices that deliver data at regular intervals, such as a heart rate monitor.

Amy Worrall
  • 16,250
  • 3
  • 42
  • 65