ActivityRings.ActivityRingsWatchAppExtension.InterfaceController.WillActivate C# (CSharp) Метод

WillActivate() публичный Метод

public WillActivate ( ) : void
Результат void
		public override void WillActivate ()
		{
			// Only proceed if health data is available.
			if (!HKHealthStore.IsHealthDataAvailable)
				return;

			// We need to be able to write workouts, so they display as a standalone workout in the Activity app on iPhone.
			// We also need to be able to write Active Energy Burned to write samples to HealthKit to later associating with our app.

			var typesToShare = new NSSet (HKQuantityType.Create (HKQuantityTypeIdentifier.ActiveEnergyBurned), HKObjectType.GetWorkoutType ());
			var typesToRead = new NSSet (HKQuantityType.Create (HKQuantityTypeIdentifier.ActiveEnergyBurned));

			HealthStore.RequestAuthorizationToShare (typesToShare, typesToRead, (bool success, NSError error) => {
				if (error != null && !success)
					Console.WriteLine ("You didn't allow HealthKit to access these read/write data types. " +
					                  "In your app, try to handle this error gracefully when a user decides not to provide access. " +
					                  $"The error was: {error.LocalizedDescription}. If you're using a simulator, try it on a device.");
			});
		}