//This method handles all the HealthKit gymnastics to remove a blood glucose entry.
        public void RemoveBloodGlucoseEntry(BloodGlucoseEntry entry)
        {
            //Cast the entry as a HealthKitBloodGlucoseEntry...
            HealthKitBloodGlucoseEntry hkBloodGlucoseEntry = entry as HealthKitBloodGlucoseEntry;

            HealthStore.DeleteObject(hkBloodGlucoseEntry.BloodGlucoseSample, new Action <bool, NSError> ((success, error) => {
                if (!success || error != null)
                {
                    //NOTE: If this app didn't put the entry into the blood glucose list, then there will be an error on delete.
                    AlertManager.ShowError("Health Kit", "Unable to delete glucose sample: " + error);
                }
                else
                {
                    //Woo! We properly removed the last entry, make sure that any listeners to the glucose states are properly updated.
                    RefreshQuantityValue(HKQuantityTypeIdentifierKey.BloodGlucose, HKObjectType.GetQuantityType(HKQuantityTypeIdentifierKey.BloodGlucose));
                }
            }));
        }
        /// <summary>
        /// This method handles all the HealthKit gymnastics to add a blood glucose entry to the HealthKit data.
        /// </summary>
        /// <param name="entry">Entry.</param>
        public void AddBloodGlucoseEntry(BloodGlucoseEntry entry)
        {
            var date         = new NSDate();
            var quantityType = HKObjectType.GetQuantityType(HKQuantityTypeIdentifierKey.BloodGlucose);
            var mgPerDL      = HKUnit.FromString("mg/dL");
            var quantity     = HKQuantity.FromQuantity(mgPerDL, entry.BloodGlucoseValue);
            var sample       = HKQuantitySample.FromType(quantityType, quantity, date, date);

            HealthStore.SaveObject(sample, new Action <bool, NSError>((success, error) => {
                if (!success || error != null)
                {
                    //There may have been an add error for some reason.
                    AlertManager.ShowError("Health Kit", "Unable to add glucose sample: " + error);
                }
                else
                {
                    //Refresh all app wide blood glucose UI fields.
                    RefreshQuantityValue(HKQuantityTypeIdentifierKey.BloodGlucose, quantityType);
                }
            }));
        }
 public void AddBloodGlucoseEntry(BloodGlucoseEntry entry)
 {
     //Google Fit doesn't support Blood Glucose, but we could add it as a custom type. Hmmmm....
     throw new NotImplementedException();
 }