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 HKQuantityType Create(HKQuantityTypeIdentifier kind) { return(HKObjectType.GetQuantityType(kind.GetConstant())); }
public static HKQuantityType Create(HKQuantityTypeIdentifier kind) { return(HKObjectType.GetQuantityType(ToKey(kind))); }