private void SaveWeight(HKHealthStore store) { var massKey = HKQuantityTypeIdentifierKey.BodyMass; var massQuantityType = HKObjectType.GetQuantityType(massKey); var currentMass = HKQuantity.FromQuantity(HKUnit.FromMassFormatterUnit(NSMassFormatterUnit.Kilogram), 77.0); var massSample = HKQuantitySample.FromType(massQuantityType, currentMass, new NSDate(), new NSDate(), new HKMetadata()); store.SaveObject(massSample, (success, error) => { Console.WriteLine("Write succeeded: " + success); if (error != null) { Console.WriteLine(error); } }); }
public override void ViewDidLoad() { base.ViewDidLoad(); var massKey = HKQuantityTypeIdentifierKey.BodyMass; var massQuantityType = HKObjectType.GetQuantityType(massKey); var hks = new HKHealthStore(); hks.RequestAuthorizationToShare(new NSSet(new [] { massQuantityType }), new NSSet(), (success, error) => { Console.WriteLine("Authorized:" + success); if (error != null) { Console.WriteLine("Authorization error: " + error); } }); this.SaveWeight(hks); }
public static HKDocumentType Create(HKDocumentTypeIdentifier kind) { return(HKObjectType._GetDocumentType(kind.GetConstant())); }
public static HKCorrelationType Create(HKCorrelationTypeIdentifier kind) { return(HKObjectType.GetCorrelationType(kind.GetConstant())); }
public static HKCharacteristicType Create(HKCharacteristicTypeIdentifier kind) { return(HKObjectType.GetCharacteristicType(kind.GetConstant())); }
public static HKCategoryType Create(HKCategoryTypeIdentifier kind) { return(HKObjectType.GetCategoryType(kind.GetConstant())); }
public static HKCategoryType Create(HKCategoryTypeIdentifier kind) { return(HKObjectType.GetCategoryType(ToKey(kind))); }
public static HKQuantityType Create(HKQuantityTypeIdentifier kind) { return(HKObjectType.GetQuantityType(ToKey(kind))); }