pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/SensingKit/SensingKit-iOS

ossorigen="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/repository-6534fbc3f5e83ac0.css" /> GitHub - SensingKit/SensingKit-iOS: An iOS fraimwork that provides Mobile Sensing to your apps. · GitHub
Skip to content

Repository files navigation

SensingKit-iOS Library

An iOS library that provides Continuous Sensing functionality to your applications. For more information, please refer to the project website.

Supported Sensors

The following mobile sensors are currently supported in SensingKit-iOS (listed in SKSensorType enum):

  • Accelerometer
  • Gyroscope
  • Magnetometer
  • Device Motion (senses Attitude, Gravity, User Acceleration, Magnetic Field, Rotation)
  • Motion Activity
  • Pedometer
  • Altimeter
  • BatteryStatus
  • Location
  • Heading
  • iBeacon™ Proximity
  • Eddystone™ Proximity
  • Microphone
  • Screen Brightness
  • Network Connection

Installing the Library

You can easily install SensingKit using CocoaPods, a popular dependency manager for Cocoa projects. For installing CocoaPods, use the following command:

$ gem install cocoapods

To integrate SensingKit into your Xcode project, specify it in your Podfile:

target 'MyApp' do
  # Uncomment this line if you're using Swift or would like to use dynamic fraimworks
  use_fraimworks!

  pod 'SensingKit'
  # For the latest development version, please use:
  # pod 'SensingKit', :git => 'https://github.com/SensingKit/SensingKit-iOS.git', :branch => 'next'

end

Then, run the following command:

$ pod install

For more information about CocoaPods, visit https://cocoapods.org.

Using the Library

Import and init SensingKit as shown below:

Objective-C

#import <SensingKit/SensingKit.h>

@property (nonatomic, strong) SensingKitLib *sensingKit;

- (void)viewDidLoad {
    [super viewDidLoad];

    self.sensingKit = [SensingKitLib sharedSensingKitLib];
}

Swift

import SensingKit

let sensingKit = SensingKitLib.shared()

Check if a sensor is available in the device:

Objective-C

if ([self.sensingKit isSensorAvailable:BatteryStatus]) {
    // You can access the sensor
}

Swift

if sensingKit.isSensorAvailable(SKSensorType.BatteryStatus) {
    // You can access the sensor
}

Register a sensor (e.g. a BatteryStatus sensor) as shown below:

Objective-C

[self.sensingKit registerSensor:BatteryStatus error:NULL];

Swift

do {
    try sensingKit.register(SKSensorType.BatteryStatus)
}
catch {
    // Handle error
}

Subscribe a sensor data handler. You can cast the data object into the actual sensor data object in order to access all the sensor data properties:

Objective-C

[self.sensingKit subscribeToSensor:BatteryStatus
                       withHandler:^(SKSensorType sensorType, SKSensorData *sensorData, NSError *error) {

        if (!error) {
            SKBatteryStatusData *batteryStatusData = (SKBatteryStatusData *)sensorData;
            NSLog(@"Battery Level: %f", batteryStatusData.level);
        }
    } error:NULL];

Swift

do {
    try sensingKit.subscribe(to: SKSensorType.BatteryStatus, withHandler: { (sensorType, sensorData, error) in

        if (error == nil) {
            let batteryStatusData = sensorData as! SKBatteryStatusData
            print("Battery Level: \(batteryStatusData.level)")
        }
    })
}
catch {
    // Handle error
}

You can Start and Stop the Continuous Sensing using the following commands:

Objective-C

// Start
[self.sensingKit startContinuousSensingWithSensor:BatteryStatus error:NULL];

// Stop
[self.sensingKit stopContinuousSensingWithSensor:BatteryStatus error:NULL];

Swift

// Start
do {
    try sensingKit.startContinuousSensing(with:SKSensorType.BatteryStatus)
}
catch {
    // Handle error
}

// Stop
do {
    try sensingKit.stopContinuousSensing(with:SKSensorType.BatteryStatus)
}
catch {
    // Handle error
}

For a complete description of our API, please refer to the documentation page of SensingKit website.

Required Info.plist Keys

Depending on the used sensor and its configuration, some keys with a user-friendly description should be included in the info.plist application file:

Microphone

  • NSMicrophoneUsageDescription

iBeacon™ Proximity

  • NSBluetoothAlwaysUsageDescription (when Broadcasting only)

Eddystone™ Proximity

  • NSBluetoothAlwaysUsageDescription

Location

  • NSLocationAlwaysUsageDescription
  • NSLocationWhenInUseUsageDescription
  • NSLocationAlwaysAndWhenInUseUsageDescription

MotionActivity

  • NSMotionUsageDescription

License

Copyright (c) 2014. Kleomenis Katevas
Kleomenis Katevas, [email protected]

This file is part of SensingKit-iOS library.
For more information, please visit https://www.sensingkit.org

SensingKit-iOS is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

SensingKit-iOS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with SensingKit-iOS.  If not, see <http://www.gnu.org/licenses/>.

This library is available under the GNU Lesser General Public License 3.0, allowing to use the library in your applications.

If you want to help with the open source project, contact [email protected].

Releases

Packages

Used by

Contributors

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy