Hi. I have a device that is connected to my phone and sends few bytes at different times. The app caches those events and sends them to server as soon as internet is available.
This all works, but when app goes to background or user locks the phone then after few seconds app has no internet access. It still caches the events that are important but unable to send them until app is brought to foreground.
How can app still connect to server?
I saw few posts saying they solved it by using URLSession with a background mode, but in my case it says:
Terminating app due to uncaught exception 'NSGenericException', reason: 'Upload tasks from NSData are not supported in background sessions.'
As I understood URLSession can download or upload files, but the events comming from BLE device are few bytes, so how to send them to server as soon as possible?
Found this stackoverflow question and gave me some hopes https://stackoverflow.com/questions/63016680/sending-network-request-after-bluetooth-update-while-ios-app-is-in-background but no examples at all.