iOS Guides | Samples

MonoTouch.HealthKit.HKHealthStore Class

MonoTouch.HealthKit.HKHealthStore A connection to the system-wide database of health-related information.

See Also: HKHealthStore

Syntax

[MonoTouch.Foundation.Register("HKHealthStore", true)]
[MonoTouch.ObjCRuntime.Introduced(MonoTouch.ObjCRuntime.PlatformName.WatchOS, 2, 0, MonoTouch.ObjCRuntime.PlatformArchitecture.None, null)]
[MonoTouch.ObjCRuntime.Introduced(MonoTouch.ObjCRuntime.PlatformName.iOS, 8, 0, MonoTouch.ObjCRuntime.PlatformArchitecture.None, null)]
public class HKHealthStore : NSObject

Remarks

Individual HKHealthStore instances represent connections to the underlying data store. Instantiating a HKHealthStore does not necessarily imply that the user has granted any amount of access for reading or querying data. App devs must call HKHealthStore.RequestAuthorizationToShare or HKHealthStore.RequestAuthorizationToShareAsync prior to access.

The result of HKHealthStore.RequestAuthorizationToShareAsync or HKHealthStore.RequestAuthorizationToShare does not indicate that the user allowed access to the requested data; it indicates only that the user interacted with the permissions dialog (or that an error occurred while presenting that dialog). To validate access to a particular data type, developers must use the HKHealthStore.GetAuthorizationStatus method:

C# Example

var temperatureKey = HKQuantityTypeIdentifierKey.BodyTemperature;
var tempQuantityType = HKObjectType.GetQuantityType (temperatureKey);

var hks = new HKHealthStore ();
var success = await hks.RequestAuthorizationToShareAsync (new NSSet (new [] { tempQuantityType }), new NSSet ());
if (success)
{
   var access = hks.GetAuthorizationStatus (tempQuantityType);
   if (access.HasFlag (HKAuthorizationStatus.SharingAuthorized)) {
	 //...etc...

Related content

Requirements

Namespace: MonoTouch.HealthKit
Assembly: monotouch (in monotouch.dll)
Assembly Versions: 0.0.0.0

The members of MonoTouch.HealthKit.HKHealthStore are listed below.

See Also: NSObject

Public Constructors

Default constructor, initializes a new instance of this class.
A constructor that initializes the object from the data stored in the unarchiver object.
Constructor to call on derived classes to skip initialization and merely allocate the object.
A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

Public Properties

[read-only]
override
ClassHandleIntPtr. The handle for this class.
[read-only]
EarliestPermittedSampleDateNSDate. Gets the earliest allowable date for samples.
[read-only]
static
IsHealthDataAvailableBoolean. Gets a value that indicates whether the user's health data is available.
[read-only]
static
UserPreferencesDidChangeNotificationNSString. Notification constant for UserPreferencesDidChange

Public Methods

AddSamples(HKSample[], HKWorkout, HKStoreSampleAddedCallback)
Links samples to a workout.
DeleteObject(HKObject, Action<bool, MonoTouch.Foundation.NSError>)
Deletes and object from the store and runs an action after it has been deleted.
DeleteObjectAsync(HKObject) : System.Threading.Tasks.Task<bool>
Deletes and object from the store and runs an action after it has been deleted.
DeleteObjects(HKObject[], Action<bool, MonoTouch.Foundation.NSError>)
Deletes the specified objects from the store and runs a completion handler when it is finished.
DeleteObjects(HKObjectType, NSPredicate, Action<bool, uint, MonoTouch.Foundation.NSError>)
Deletes the objects that match the specified objectType and predicate from the store and runs a completion handler when it is finished.
DeleteObjectsAsync(HKObject[]) : System.Threading.Tasks.Task<bool>
Deletes the specified from the store and runs a completion handler when it is finished.
DisableAllBackgroundDelivery(Action<bool, MonoTouch.Foundation.NSError>)
Disables the background delivery of notifications and runs an action after delivery has been disabled.
DisableBackgroundDelivery(HKObjectType, Action<bool, MonoTouch.Foundation.NSError>)
Disables the background delivery of notifications of the specified type and runs an action after delivery has been disabled.
EnableBackgroundDelivery(HKObjectType, HKUpdateFrequency, Action<bool, MonoTouch.Foundation.NSError>)
Enable the background delivery of notifications of the specified type and runs an action after delivery has been disabled.
ExecuteQuery(HKQuery)
Runs a query.
GetAuthorizationStatus(HKObjectType) : HKAuthorizationStatus
Returns the authorization status for type.
GetBiologicalSex(out NSError) : HKBiologicalSexObject
Returns the user's biological sex.
GetBloodType(out NSError) : HKBloodTypeObject
Returns the user's blood type.
GetDateOfBirth(out NSError) : NSDate
Returns the user's date of birth.
GetDateOfBirthComponents(out NSError) : NSDateComponents
Attempts to return the date components for the user's date of birth, and reports any errors that it encounters in the out parameter, error.
GetFitzpatrickSkinType(out NSError) : HKFitzpatrickSkinTypeObject
Attempts to return the Fitzpatrick skin type for the user, and reports any errors that it encounters in the out parameter, error.
GetPreferredUnits(NSSet, Action<MonoTouch.Foundation.NSDictionary, MonoTouch.Foundation.NSError>)
Asynchronously calls completion, passing in a NSDictionary of HKQuantityType->HKUnit.
GetPreferredUnitsAsync(NSSet) : System.Threading.Tasks.Task<MonoTouch.Foundation.NSDictionary>
Asynchronously calls , passing in a of ->.
GetWheelchairUse(out NSError) : HKWheelchairUseObject
Attempts to return the wheelchair use for the user, and reports any errors that it encounters in the out parameter, error.
HandleAuthorizationForExtension(Action<bool, MonoTouch.Foundation.NSError>)
Requests authorization for an extension to read and write data, and runs a completion handler that receives a Boolean success value and an error object.
RequestAuthorizationToShare(NSSet, NSSet, Action<bool, MonoTouch.Foundation.NSError>)
Requests autorization to save and read user data and runs an action after a determination has been made.
RequestAuthorizationToShareAsync(NSSet, NSSet) : System.Threading.Tasks.Task<bool>
Requests autorization to save and read user data and runs an action after a determination has been made.
SaveObject(HKObject, Action<bool, MonoTouch.Foundation.NSError>)
Saves obj and runs completion when finished.
SaveObjectAsync(HKObject) : System.Threading.Tasks.Task<bool>
Saves and runs when finished.
SaveObjects(HKObject[], Action<bool, MonoTouch.Foundation.NSError>)
Saves the objects that are contained in objects and runs completion when finished.
SaveObjectsAsync(HKObject[]) : System.Threading.Tasks.Task<bool>
Saves the objects that are contained in and runs when finished.
SplitTotalEnergy(HKQuantity, NSDate, NSDate, Action<HKQuantity, HKQuantity, MonoTouch.Foundation.NSError>)
Splits totalEnergy into resting and active energy portions, and calls a handler with the result.
StartWatchApp(HKWorkoutConfiguration, Action<bool, MonoTouch.Foundation.NSError>)
Launches or wakes the Watch app for the workout.
StartWatchAppAsync(HKWorkoutConfiguration) : System.Threading.Tasks.Task<bool>
Launches or wakes the Watch app for the workout.
StopQuery(HKQuery)
Stops the specified in-progress query