Welcome! Sign in or Register to get your developer token.

Overview

Overview

iOS SDK

Installation Connecting Reading Stats Types

Android SDK

Installation Connecting Reading Stats Types

React Native

Demo App

Web API

Authenticating

Initialization and Connection

Before the BACtrack API can be used to communicate with a BACtrack device, it must first be initialized, like so:

BACTrackAPI bacTrack = [[BacTrackAPI alloc] initWithDelegate:delegate AndAPIKey:@""];

The returned BACTrackAPI instance features all the methods and callbacks you need in order to communicate with BACtrack devices.

A valid API key must be provided to the init method. The API Key can be obtained by signing in to this page with a valid BACtrack subscription. In the case that your app has not been approved to use our SDK, the callback (void)[BacTrackAPIKeyDeclined]:(NSString *)errorMessage will be called. This callback is not optional.

Connecting to the Nearest Device

Once you’ve initialized your BacTrackAPI object, you can establish a BTLE connection between iOS and BACtrack devices calling connectToNearestBreathalyzer on your BacTrackAPI object.

Initialize Class

-(id)initWithDelegate:(id<BacTrackAPIDelegate> )delegate AndAPIKey:(NSString*)api_key;

You must initialize the BACtrackAPI delegate before calling any other commands. A valid API key is required, and can be obtained by signing on this page with a valid subscription.

Connect to Nearest Breathalyzer

-(void)connectToNearestBreathalyzer

Connect to the nearest breathalyzer device.

Scan for Breathalyzers

-(void)startScan Scan for BACtracks within range. When breathalyzers are discovered, your BacTrackFoundBreathalyzer callback will be called. Also see: connectBreathalyzer:withTimeout:

Stop Scanning for Breathalyzers

-(void)stopScan stopScan cancels any current breathalyzer scan.

Connect to Specific Breathalyzer

-(void)connectBreathalyzer:(Breathalyzer*)breathalyzer withTimeout:(NSTimeInterval)timeout Connect to a specific breathalyzer. The breathalyzer object is retrieved from your BacTrackFoundBreathalyzer callback (see: startScan).

Disconnect from the Breathalyzer

-(void)disconnect Disconnects from the connected BACtrack.

Delegate Reference

API Key Authorized

-(void)BacTrackAPIKeyAuthorized This is called when the API key passed into initWithDelegate:withAPIKey is valid.

API Key Declined (Required)

-(void)BacTrackAPIKeyDeclined:(NSString *)errorMessage This is called when the API key passed into initWithDelegate:withAPIKey is not valid or has been otherwise declined.

BACtrack Connected

-(void)[BacTrackConnected]:(BACtrackDeviceType)device This is called when the API has successfully connected to BACtrack and found its services and characteristics.

BACtrack Disconnected

-(void) BacTrackDisconnected Called when the API has disconnected from the BACtrack device.

BACtrack Connection Timed Out

-(void)BacTrackConnectTimeout This is called when the BACtrack connection was unsuccessful because it timed out

BACtrack Request Timeout Duration

-(NSTimeInterval)BacTrackGetTimeout Return the desired timeout, in seconds, when attempting to connect to a breathalyzer.

BACtrack Device Discovered

-(void)BacTrackFoundBreathalyzer:(Breathalyzer*)breathalyzer This is called when startScan discovers a breathalyzer. It will be called for each breathalyzer device discovered.