Skip to content

PPG Device Session

Besides measurements using the camera, the SDK also supports Vital Sign measurements using Polar Verity Sense device.

Creating a PPG Device session is done by using the PolarSessionBuilder API

Swift
do {
    let licenseDetails = LicenseDetails(licenseKey: "<ENTER_YOUR_LICENSE_KEY>")
    let deviceID = "<ENTER_POLAR_DEVICE_ID>"
    let session = try PolarSessionBuilder(polarDeviceID: deviceID)
        .withSessionInfoListener(self)
        .withVitalSignsListener(self)
        .withPPGDeviceInfoListener(self)
        .build(licenseDetails: licenseDetails)
}
catch {
    let e = error as NSError
    print("Received Error. Domain: \(e.domain) Code: \(e.code)")
}
do {
    let licenseDetails = LicenseDetails(licenseKey: "<ENTER_YOUR_LICENSE_KEY>")
    let deviceID = "<ENTER_POLAR_DEVICE_ID>"
    let session = try PolarSessionBuilder(polarDeviceID: deviceID)
        .withSessionInfoListener(self)
        .withVitalSignsListener(self)
        .withPPGDeviceInfoListener(self)
        .build(licenseDetails: licenseDetails)
}
catch {
    let e = error as NSError
    print("Received Error. Domain: \(e.domain) Code: \(e.code)")
}
Objective-c
BNHLicenseDetails *licenseDetails = [[BNHLicenseDetails alloc] initWithLicenseKey:@"<ENTER_YOUR_LICENSE_KEY>"];
NSString *deviceID = @"<ENTER_POLAR_DEVICE_ID>";
BNHSessionBuilder *sessionBuilder = [[[[[BNHPolarSessionBuilder alloc] initWithPolarDeviceID:deviceID]
                                       withVitalSignsListener:self]
                                      withSessionInfoListener:self]
                                     withPPGDeviceInfoListener:self];

NSError *error = nil;
id<BNHSession> _Nullable session = [sessionBuilder buildWithLicenseDetails:licenseDetails
                                                                     error:&error];
if (error != nil) {
    NSLog(@"Received Error. Domain: %@ Code: %ld", error.domain, (long)error.code);
}
BNHLicenseDetails *licenseDetails = [[BNHLicenseDetails alloc] initWithLicenseKey:@"<ENTER_YOUR_LICENSE_KEY>"];
NSString *deviceID = @"<ENTER_POLAR_DEVICE_ID>";
BNHSessionBuilder *sessionBuilder = [[[[[BNHPolarSessionBuilder alloc] initWithPolarDeviceID:deviceID]
                                       withVitalSignsListener:self]
                                      withSessionInfoListener:self]
                                     withPPGDeviceInfoListener:self];

NSError *error = nil;
id<BNHSession> _Nullable session = [sessionBuilder buildWithLicenseDetails:licenseDetails
                                                                     error:&error];
if (error != nil) {
    NSLog(@"Received Error. Domain: %@ Code: %ld", error.domain, (long)error.code);
}

During session initialization, the SDK attempts to connect with the specified PPG Device using the provided device type and device ID. The session transitions to the ready state only when the connection is established. Session creation may fail for various reasons, such as disabled Bluetooth on the mobile device or an outdated PPG device firmware. For detailed error information, please consult the Alerts List.