Hello. I have implemented background delivery for detecting changes in health kit with HKObserverQuery. It works well, I am reading changes. And I am sending this changes to an https endpoint with using an URLSession.shared.dataTask inside the HKObserverQuery callback while my app is terminated. I have several questions about this:
- Is starting a URLSession.shared.dataTask inside HKObserverQuery callback when app is terminated is correct way to do it?
- I am calling HKObserverQuery completion handler whatever dataTask returned success or failure but I am wondering what if the network connection is low and this dataTask response could not received in 2-3 seconds. I have read background deliveries should take 1-2 seconds. Should I use an URL session with background configuration for sending those HTTPS requests? If so, should I use download task or upload task (they don't fit my requirements I am sending a simple json)?
In a situation like this, where the system has resumed or relaunched your app in the background to tell it about a specific event, you have to decide whether you want to use a standard session or a background session. I talk more about this trade-off in my reply on this thread.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"