0

I’m currently working on a project using BLE device. Every 15min, the device send a status to the app. While the app is on background state, the request sent by this device wakes up the app. Based on apple documentation, the application could only have around 10 seconds to execute background task: https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html

The questions are: is it allowed by the system to have this behavior on background ? Is it not going to kill the application ? Do we have 10 sec each time the application is wake up ?

plpb
  • 1
  • Yes. You have a few seconds each time your app is resumed in the background. You should also ensure that you set up Core Bluetooth state restoration so that iOS can relaunch your app in response to Bluetooth events in the case where it has been terminated. – Paulw11 May 02 '23 at 06:48
  • If you just wanted to share a data from bluetooth device to your app then it will work in background regardless of time - check this delegate method of CBCentralManagerDelegate https://developer.apple.com/documentation/corebluetooth/cbcentralmanagerdelegate/1518819-centralmanager – Saurabh Prajapati May 02 '23 at 07:01
  • Thanks @Paulw11 for your reply :) Last quick question: If I call beginBackgroundTask every time to get more time when the request wakes up the app, what behavior will I get? about 30 sec each time or the time given by the system will decrease considerably or even be zero? – plpb May 02 '23 at 07:06
  • You really only need to call that if you are going to do more than 30 seconds work. You will probably do less than that. If you do start a background task, as long as you stop running in response to the expiration handler you should not be terminated. – Paulw11 May 02 '23 at 08:16

0 Answers0