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
SensingKitLibinstance, creating it if necessary.Declaration
Objective-C
+ (nonnull SensingKitLib *)sharedSensingKitLib;Swift
class func shared() -> SensingKitLibReturn Value
The shared
SensingKitLibinstance. -
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) -> StringParameters
sensorTypeThe type of the sensor for which the CSV Header will be returned.
Return Value
A string with a CSV header.
-
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) -> BoolParameters
sensorTypeThe 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) -> BoolParameters
sensorTypeThe 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) -> BoolParameters
sensorTypeThe type of the sensor that will be checked.
Return Value
YES if the sensor is currently sensing or NO if it is not.
-
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) throwsParameters
sensorTypeThe type of the sensor that will be initialized and registered in the library.
errorThis 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?) throwsParameters
sensorTypeThe type of the sensor that will be initialized and registered in the library.
configurationA configuration object that conforms to SKConfiguration. If no configuration is specified, it will default to a pre-determined sensor configuration.
errorThis 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) throwsParameters
sensorTypeThe type of the sensor that will be deregistered.
errorThis 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) throwsParameters
configurationA configuration object that conforms to SKConfiguration. If no configuration is specified, it will default to a pre-determined sensor configuration.
sensorTypeThe type of the sensor that will be configured.
errorThis 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 -> SKConfigurationParameters
sensorTypeThe type of the sensor.
errorThis pointer is NULL if the action was performed successfully.
Return Value
The configuration of that particular sensor, or nil if an error has occured.
-
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) throwsParameters
sensorTypeThe type of the sensor that the data handler will be subscribed to.
handlerA block that is invoked with each update to handle new sensor data. The block must conform to the SKSensorDataHandler type.
errorThis 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) throwsParameters
sensorTypeThe type of the sensor for which all block handlers will be unsubscribed.
errorThis 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 the specified sensor.
Declaration
Objective-C
- (BOOL)startContinuousSensingWithSensor:(SKSensorType)sensorType error:(NSError *_Nullable *_Nullable)error;Swift
func startContinuousSensing(with sensorType: SKSensorType) throwsParameters
sensorTypeThe type of the sensor that will be started.
errorThis 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) throwsParameters
sensorTypeThe type of the sensor that will be stopped.
errorThis 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() throwsParameters
errorThis 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() throwsParameters
errorThis 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.
View on GitHub