HealthKit Distribution Remove to End

I hope this question doesn’t sound too stupid, but so far I have not been able to find a solution. I am currently writing an application using Xamarin that integrates with HealthKit. Data stored in HK is periodically synchronized with the server. This is done using the HKAnchoredObjectQuery, which pulls feed correlations.

Because data is periodically pulled, a scenario arises that between synchronizations can delete a user in HealthKit. This deletion should be sent back to the server at the next synchronization.

My initial thought was to do this with an Observer query.

My Question : Using the Observer request for HealthKit, is there a way to determine if the action that caused the request is a delete action?

public void CheckForDelete (Subject subject)
    {
        var sampleType = HKObjectType.GetCorrelationType (HKCorrelationTypeKey.IdentifierFood);
        var predicate = HKQuery.GetPredicateForSamples (NSDate.DistantPast, NSDate.Now, HKQueryOptions.None);
        var observerQuery = new HKObserverQuery (sampleType, predicate, (query, completion, error ) => {
            //...Determine if action was a Delete
            //Code to delete on backend

            completion();
        });

        HealthKitStore.ExecuteQuery (observerQuery);
    }
+4
source share
1 answer

In iOS 9, has HKAnchoredObjectQuerybeen modified to send deleted objects.

+1
source

All Articles