SensingKitLib

Objective-C

@interface SensingKitLib : NSObject

Swift

class SensingKitLib : NSObject

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

  • Unavailable

    Undocumented

    Declaration

    Objective-C

    - (instancetype)init NS_UNAVAILABLE;
  • Returns the shared SensingKitLib instance, creating it if necessary.

    Declaration

    Objective-C

    + (nonnull SensingKitLib *)sharedSensingKitLib;

    Swift

    class func shared() -> SensingKitLib

    Return Value

    The shared SensingKitLib instance.

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

    Declaration

    Objective-C

    - (nonnull NSString *)csvHeaderForSensor:(SKSensorType)sensorType;

    Swift

    func csvHeader(for sensorType: SKSensorType) -> String

    Parameters

    sensorType

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

    Return Value

    A string with a CSV header.

Sensor Status */

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

    Declaration

    Objective-C

    - (BOOL)isSensorAvailable:(SKSensorType)sensorType;

    Swift

    func isSensorAvailable(_ sensorType: SKSensorType) -> Bool

    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.

  • A Boolean value that indicates whether the sensor is registered.

    Declaration

    Objective-C

    - (BOOL)isSensorRegistered:(SKSensorType)sensorType;

    Swift

    func isSensorRegistered(_ sensorType: SKSensorType) -> Bool

    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.

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

    Declaration

    Objective-C

    - (BOOL)isSensorSensing:(SKSensorType)sensorType;

    Swift

    func isSensorSensing(_ sensorType: SKSensorType) -> Bool

    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.

Sensor Registration and Configuration */

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

    Declaration

    Objective-C

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

    Swift

    func register(_ sensorType: SKSensorType) throws

    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.

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

    Declaration

    Objective-C

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

    Swift

    func register(_ sensorType: SKSensorType, with configuration: SKConfiguration?) throws

    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.

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

    Declaration

    Objective-C

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

    Swift

    func deregister(_ sensorType: SKSensorType) throws

    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.

  • Provides custom configuration to a sensor.

    Declaration

    Objective-C

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

    Swift

    func setConfiguration(_ configuration: SKConfiguration?, to sensorType: SKSensorType) throws

    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.

  • Gets the configuration of a sensor.

    Declaration

    Objective-C

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

    Swift

    func getConfigurationFrom(_ sensorType: SKSensorType) throws -> SKConfiguration

    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.

Sensor Subscription */

  • Subscribes for sensor updates using a specified block handler.

    Declaration

    Objective-C

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

    Swift

    func subscribe(to sensorType: SKSensorType, withHandler handler: @escaping SKSensorDataHandler) throws

    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.

  • Unsubscribes all block handlers.

    Declaration

    Objective-C

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

    Swift

    func unsubscribeAllHandlers(from sensorType: SKSensorType) throws

    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.

Continuous Sensing */

  • Starts continuous sensing with the specified sensor.

    Declaration

    Objective-C

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

    Swift

    func startContinuousSensing(with sensorType: SKSensorType) throws

    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.

  • Stops continuous sensing with the specified sensor.

    Declaration

    Objective-C

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

    Swift

    func stopContinuousSensing(with sensorType: SKSensorType) throws

    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.

  • Starts continuous sensing with all registered sensors.

    Declaration

    Objective-C

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

    Swift

    func startContinuousSensingWithAllRegisteredSensors() throws

    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.

  • Stops continuous sensing with all registered sensors.

    Declaration

    Objective-C

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

    Swift

    func stopContinuousSensingWithAllRegisteredSensors() throws

    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.