Beispiel #1
0
        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);
                }
            });
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 public static HKDocumentType Create(HKDocumentTypeIdentifier kind)
 {
     return(HKObjectType._GetDocumentType(kind.GetConstant()));
 }
Beispiel #4
0
 public static HKCorrelationType Create(HKCorrelationTypeIdentifier kind)
 {
     return(HKObjectType.GetCorrelationType(kind.GetConstant()));
 }
Beispiel #5
0
 public static HKCharacteristicType Create(HKCharacteristicTypeIdentifier kind)
 {
     return(HKObjectType.GetCharacteristicType(kind.GetConstant()));
 }
Beispiel #6
0
 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)));
 }