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

– 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.

- (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

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.

error

This pointer is NULL if the action was performed successfully.

Return Value

YES if the action was performed successfully, or NO if an error has occuried.

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.

error

This pointer is NULL if the action was performed successfully.

Return Value

YES if the action was performed successfully, or NO if an error has occuried.

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.

error

This pointer is NULL if the action was performed successfully.

Return Value

YES if the action was performed successfully, or NO if an error has occuried.

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.

error

This pointer is NULL if the action was performed successfully.

Return Value

YES if the action was performed successfully, or NO if an error has occuried.

Declared In

SensingKitLib.h

– getConfigurationFromSensor:error:

Gets the configuration of a sensor.

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

Parameters

sensorType

The type of the sensor.

error

This pointer is NULL if the action was performed successfully.

Return Value

The configuration of that particular sensor, or nil if an error has occured.

Declared In

SensingKitLib.h

Sensor Subscription

– subscribeToSensor:withHandler:error:

Subscribes for sensor updates using a specified block handler.

- (BOOL)subscribeToSensor:(SKSensorType)sensorType withHandler:(SKSensorDataHandler)handler error:(NSError *_Nullable *_Nullable)error

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.

error

This pointer is NULL if the action was performed successfully.

Return Value

YES if the action was performed successfully, or NO if an error has occuried.

Declared In

SensingKitLib.h

– unsubscribeAllHandlersFromSensor:error:

Unsubscribes all block handlers.

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

Parameters

sensorType

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

error

This pointer is NULL if the action was performed successfully.

Return Value

YES if the action was performed successfully, or NO if an error has occuried.

Declared In

SensingKitLib.h

Continuous Sensing

– startContinuousSensingWithSensor:error:

Starts continuous sensing with the specified sensor.

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

Parameters

sensorType

The type of the sensor that will be started.

error

This pointer is NULL if the action was performed successfully.

Return Value

YES if the action was performed successfully, or NO if an error has occuried.

Declared In

SensingKitLib.h

– stopContinuousSensingWithSensor:error:

Stops continuous sensing with the specified sensor.

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

Parameters

sensorType

The type of the sensor that will be stopped.

error

This pointer is NULL if the action was performed successfully.

Return Value

YES if the action was performed successfully, or NO if an error has occuried.

Declared In

SensingKitLib.h

– startContinuousSensingWithAllRegisteredSensors:

Starts continuous sensing with all registered sensors.

- (BOOL)startContinuousSensingWithAllRegisteredSensors:(NSError *_Nullable *_Nullable)error

Parameters

error

This pointer is NULL if the action was performed successfully.

Return Value

YES if the action was performed successfully, or NO if an error has occuried.

Declared In

SensingKitLib.h

– stopContinuousSensingWithAllRegisteredSensors:

Stops continuous sensing with all registered sensors.

- (BOOL)stopContinuousSensingWithAllRegisteredSensors:(NSError *_Nullable *_Nullable)error

Parameters

error

This pointer is NULL if the action was performed successfully.

Return Value

YES if the action was performed successfully, or NO if an error has occuried.

Declared In

SensingKitLib.h