SensingKitLib Class Reference

Inherits from NSObject
Declared in SensingKitLib.h

Overview

The ‘SensingKitLib’ class is the main class of SensingKit library that manages all supported sensors. It uses the Singleton design pattern so that only one instance of the library exists in the application. To init it, you can use [SensingKitLib sharedSensingKitLib].

Other Methods

+ sharedSensingKitLib

Returns the shared SensingKitLib instance, creating it if necessary.

+ (SensingKitLib *)sharedSensingKitLib

Return Value

The shared SensingKitLib instance.

Declared In

SensingKitLib.h

Sensor Status

– isSensorAvailable:

A Boolean value that indicates whether the sensor is available on the device. This method should always be used before using a sensor.

- (BOOL)isSensorAvailable:(SKSensorType)sensorType

Parameters

sensorType

The type of the sensor that will be checked.

Return Value

YES if the sensor is available or NO if it is not.

Declared In

SensingKitLib.h

– isSensorRegistered:

A Boolean value that indicates whether the sensor is registered.

- (BOOL)isSensorRegistered:(SKSensorType)sensorType

Parameters

sensorType

The type of the sensor that will be checked.

Return Value

YES if the sensor is registered or NO if it is not.

Declared In

SensingKitLib.h

– isSensorSensing:

A Boolean value that indicates whether the sensor is currently sensing.

- (BOOL)isSensorSensing:(SKSensorType)sensorType

Parameters

sensorType

The type of the sensor that will be checked.

Return Value

YES if the sensor is currently sensing or NO if it is not.

Declared In

SensingKitLib.h

Sensor Registration and Configuration

– registerSensor:error:

Initializes and registers a sensor into the library with a default sensor configuration.

- (BOOL)registerSensor:(SKSensorType)sensorType error:(NSError *_Nullable *_Nullable)error

Parameters

sensorType

The type of the sensor that will be initialized and registered in the library.

Declared In

SensingKitLib.h

– registerSensor:withConfiguration:error:

Initializes and registers a sensor into the library with a custom sensor configuration.

- (BOOL)registerSensor:(SKSensorType)sensorType withConfiguration:(nullable SKConfiguration *)configuration error:(NSError *_Nullable *_Nullable)error

Parameters

sensorType

The type of the sensor that will be initialized and registered in the library.

configuration

A configuration object that conforms to SKConfiguration. If no configuration is specified, it will default to a pre-determined sensor configuration.

Declared In

SensingKitLib.h

– deregisterSensor:error:

Deregisters a sensor from the library. Sensor should not be actively sensing when this method is called. All previously subscribed blocks will also be unsubscribed.

- (BOOL)deregisterSensor:(SKSensorType)sensorType error:(NSError *_Nullable *_Nullable)error

Parameters

sensorType

The type of the sensor that will be deregistered.

Declared In

SensingKitLib.h

– setConfiguration:toSensor:error:

Provides custom configuration to a sensor.

- (BOOL)setConfiguration:(nullable SKConfiguration *)configuration toSensor:(SKSensorType)sensorType error:(NSError *_Nullable *_Nullable)error

Parameters

configuration

A configuration object that conforms to SKConfiguration. If no configuration is specified, it will default to a pre-determined sensor configuration.

sensorType

The type of the sensor that will be configured.

Declared In

SensingKitLib.h

– getConfigurationFromSensor:error:

Gets the configuration of a sensor.

- (SKConfiguration *)getConfigurationFromSensor:(SKSensorType)sensorType error:(NSError *_Nullable *_Nullable)error

Parameters

sensorType

The type of the sensor.

Return Value

The configuration of that particular sensor.

Declared In

SensingKitLib.h

Sensor Subscription

– subscribeToSensor:withHandler:

Subscribes for sensor updates using a specified block handler.

- (void)subscribeToSensor:(SKSensorType)sensorType withHandler:(SKSensorDataHandler)handler

Parameters

sensorType

The type of the sensor that the data handler will be subscribed to.

handler

A block that is invoked with each update to handle new sensor data. The block must conform to the SKSensorDataHandler type.

Declared In

SensingKitLib.h

– unsubscribeAllHandlersFromSensor:

Unsubscribes all block handlers.

- (void)unsubscribeAllHandlersFromSensor:(SKSensorType)sensorType

Parameters

sensorType

The type of the sensor for which all block handlers will be unsubscribed.

Declared In

SensingKitLib.h

– csvHeaderForSensor:

A string with a CSV formatted header that describes the data of the particular sensor. This method is useful in combination with the csvString instance method of an SKSensorData object.

- (nullable NSString *)csvHeaderForSensor:(SKSensorType)sensorType

Parameters

sensorType

The type of the sensor for which the CSV Header will be returned.

Return Value

A string with a CSV header.

Declared In

SensingKitLib.h

Continuous Sensing

– startContinuousSensingWithSensor:

Starts continuous sensing with the specified sensor.

- (void)startContinuousSensingWithSensor:(SKSensorType)sensorType

Parameters

sensorType

The type of the sensor that will be started.

Declared In

SensingKitLib.h

– stopContinuousSensingWithSensor:

Stops continuous sensing with the specified sensor.

- (void)stopContinuousSensingWithSensor:(SKSensorType)sensorType

Parameters

sensorType

The type of the sensor that will be stopped.

Declared In

SensingKitLib.h

– startContinuousSensingWithAllRegisteredSensors

Starts continuous sensing with all registered sensors.

- (void)startContinuousSensingWithAllRegisteredSensors

Declared In

SensingKitLib.h

– stopContinuousSensingWithAllRegisteredSensors

Stops continuous sensing with all registered sensors.

- (void)stopContinuousSensingWithAllRegisteredSensors

Declared In

SensingKitLib.h