Currently developing a medical device app in React Native that needs to constantly run in the background to save data from the ble device.
Is there a way to do this instead of using the background fetch that only runs periodically?
Currently developing a medical device app in React Native that needs to constantly run in the background to save data from the ble device.
Is there a way to do this instead of using the background fetch that only runs periodically?
Currently developing a medical device app
What platform are you targeting?
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Currently only going to be on iphones for ios devices.
OK. You tagged your question with IOBluetooth, which is a Mac-specific technology, and hence my confusion. I’ve changed that to Core Bluetooth.
iOS puts strict limits on background execution. See my iOS Background Execution Limits post for some… background… to this. So, there’s no way to do this specifically:
[my app] needs to constantly run in the background
However, Core Bluetooth does support a background mode that resumes (or relaunches) your app in the background in response to activity on a peripheral. This is outside of my area of expertise, but I’m hoping that the change of tags will attract a Core Bluetooth expert.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Well, if you’re going to pivot into the networking side of this, I can help you out (-:
During that background relaunch for the app from Core Bluetooth, are we allowed to also do some network tasks?
iOS supports networking in the background as long as your process isn’t suspended. So, if you have small network requests you can take steps to prevent your app from being suspended (see my UIApplication Background Task Notes post) and run your networking directly.
However, the system will only let you run for a very short period of time in the background (we’re talking seconds here). If you need to run a large network request you’ll have to pass that work off to the system to perform while you’re suspended. You typically do this using an NSURLSession
background session.
Also keep in mind that in poor network conditions even a tiny request might take a long time. You’ll need to decide on how to deal with that. You could, for example, buffer the request and send it next time. Or use a hybrid approach, and hand these delayed requests of to an an NSURLSession
background session.
does it increase the chance of it running in Background Fetch since it technically launched again?
No.
I very much doubt that the background fetch mechanism will be useful to you here. I recommend that you watch WWDC 2020 Session 10063 Background execution demystified, which explains the thinking behind that facility.
If your server needs to resume your app in the background, a ‘silent’ push notification is the best option. Although be aware that the system puts significant limits on how many of these it will deliver to your app in the background, so it’s best to reserve that budget for when you need it. If you send a silent push every minute, you’ll quickly burn through your budget and you’ll get no more for a while.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"