'Background Task to Fetch HealthKit Data

I am using iOS 13 where Background Task framework there. My Query is

  1. Can it will be possible to fetch HealthKit Data in Background Mode.

  2. Can i send these Healthkit data to My server using Post request using backbround mode. Please help me out and provide your guidelines .



Solution 1:[1]

Yes it is possible to fetch data in background mode. You must run a HKObserverQuery and enable background deliveries.

HKObserverQuery docs: https://developer.apple.com/documentation/healthkit/hkobserverquery/executing_observer_queries

Enabling background deliveries docs: https://developer.apple.com/documentation/healthkit/hkhealthstore/1614175-enablebackgrounddelivery

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 gggava