Skip to content

SDK Integration

Once you receive the BinahAI.framework file, you are ready to add the SDK to your application.

Follow the steps below to integrate the SDK into your application.

1. Choosing the Appropriate Framework According to Your Business Needs

Binah provides two zip archives, each contains a different flavour of the Binah.ai framework:

  1. Binah_iOS_SDK_XXX.zip - this zip file includes a framework for Camera Sessions Only - Use this framework if your business case requires only camera-based sessions.

  2. Binah_Polar_iOS_SDK_XXX.zip - this zip file includes a framework for Camera Sessions and Polar Sessions using an External PPG Device - Use this framework if your business case requires the use of the Polar Verity Sense external PPG sensor in addition to camera-based sessions. Please be aware that this framework embeds some additional third-party libraries, which may potentially cause conflicts with libraries used by your application. Therefore, it is advised to use this framework only when external PPG sessions are intended. This framework includes the following embedded libraries:

    • PolarBleSdk (version 5.1.0)
    • RxSwift (version 6.5.0)
    • SwiftProtobuf (version 1.6.0 or later)

Please note that in both cases the name of the framework itself inside the zip file is BinahAI.framework. To determine the framework type, follow the steps below:

  • Open the BinahAI.framework
  • Open Info.plist file
  • Find the Mode setting and check for its value:
    • PRODUCTION indicates support for camera-based sessions only (option 1 above).
    • PRODUCTION_POLAR indicates support for both camera-based sessions and Polar-based sessions (option 2 above).

2. Add the Framework to your Project

  • Create a Frameworks directory under your project root.
  • Copy the the BinahAI.framework into the Frameworks directory.
  • Drag and drop the BinahAI.framework file into your Xcode project.
  • Ensure that the Copy items if needed checkbox is checked, and that your app target is checked in the Add to targets section.

The following screenshot is taken from the SDK Sample App. img

3. Embed the Framework

In order for your app to use the BinahAI Framework, it must be embedded in your app. To do this, follow these steps:

  • Select your app target in the project navigator.
  • Select the General tab.
  • Scroll down to the Frameworks, Libraries, and Embedded Content section.
  • Ensure that the BinahAI.framework is set to "Embed & Sign".

The following screenshot is taken from the SDK Sample App. img

4. Import the BinahAI Framework

In your code, import the Binah Framework by adding the following line at the top of your file:

Swift
import BinahAI
import BinahAI
Objective-C
#import <BinahAI/BinahAI.h>
#import <BinahAI/BinahAI.h>

5. Add the Necessary Permissions

For the proper functioning of the SDK, specific permissions need to be included in your application's Info.plist file, depending on your use case.

Camera Permissions (Face/Finger Sessions)

To request camera permissions for face measurements, include the following section:

xml
<key>NSCameraUsageDescription</key>
<string>App needs camera access for health measurement, without capturing or storing images or facial characteristics.</string>
<key>NSCameraUsageDescription</key>
<string>App needs camera access for health measurement, without capturing or storing images or facial characteristics.</string>

Bluetooth Permissions (PPG Devices Sessions)

To request Bluetooth permissions for connecting with Bluetooth PPG devices and enabling Polar measurements, include the following section:

xml
<key>NSBluetoothAlwaysUsageDescription</key>
<string>App needs Bluetooth access for health measurement.</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>App needs Bluetooth access for health measurement.</string>

Background Permissions (PPG Devices Sessions)

For background operation during Polar measurements (note that face measurements require foreground operation), add the following section:

xml
<key>UIBackgroundModes</key>
<array>
    <string>bluetooth-central</string>
</array>
<key>UIBackgroundModes</key>
<array>
    <string>bluetooth-central</string>
</array>

6. Allow application run on simulator with Binah SDK

The Binah SDK is compiled for arm64 architectures and is not compatible with x86_64, making it incompatible with the Xcode simulator.

To compile and run your application on a simulator by bypassing the SDK, follow the instructions below:

  • Go to Build Settings

    • Option A - ArchitecturesExcluded Architectures and add arm64 under Any iOS Simulator SDK

    img

    • Option B - Build Options and change the property value of Validate Workspace to YES.
  • Wrap SDK calls with if-else-endif syntax:

    Swift
    #if targetEnvironment(simulator)
      // Code specific to the iOS Simulator
    #else
      // Code for running on a real iOS device
    #endif
    #if targetEnvironment(simulator)
      // Code specific to the iOS Simulator
    #else
      // Code for running on a real iOS device
    #endif
    Objective-C
    #if TARGET_OS_SIMULATOR
      // Code specific to the iOS Simulator
    #else
      // Code for running on a real iOS device
    #endif
    #if TARGET_OS_SIMULATOR
      // Code specific to the iOS Simulator
    #else
      // Code for running on a real iOS device
    #endif

    Assisting error messages can make it easier to determine which code needs to be wrapped.

7. Handling minimum deployment target errors

If your project's minimum deployment target is set to a version below 14.0, you will encounter an error stating 'available only in iOS 14.0 or newer.'

To handle this error, you can use the following code:

Swift
if #available(iOS 14.0, *) {
  // Code that should run on iOS 14.0 or later
} else {
  // Code that runs on iOS versions earlier than 14.0
}
if #available(iOS 14.0, *) {
  // Code that should run on iOS 14.0 or later
} else {
  // Code that runs on iOS versions earlier than 14.0
}
Objective-C
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000
  // Code that should run on iOS 14.0 or later
#else
  // Code that runs on earlier iOS versions
#endif
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000
  // Code that should run on iOS 14.0 or later
#else
  // Code that runs on earlier iOS versions
#endif