SensingKit/SensingKit-iOS

Not able to retrieve any data from sensors

Closed this issue · 1 comments

For the life of me I can not figure out how to get this library to work. I've tried everything in the README and used my own knowledge to try different alternatives.

My code is:

#import "ViewController.h"
#import <SensingKit/SensingKit.h>

@interface ViewController ()
@property (nonatomic, strong) SensingKitLib *sensingKit;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    self.sensingKit = [SensingKitLib sharedSensingKitLib];
    
    [self.sensingKit subscribeToSensor:Battery withHandler:^(SKSensorType sensorType, SKSensorData *sensorData, NSError *error) {
        if (!error) {
            SKBatteryData *batteryData = (SKBatteryData *)sensorData;
            NSLog(@"Battery Level: %f", batteryData.level);
        }
        else {
            NSLog(@"ERROR = %@", error);
        }
    } error:NULL];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end

I get nothing in the console and no error....

Hello. Sorry to hear you are having issues. Battery need to change in order to report an update (e.g. drop by 1%). Can you please try a different sensor?