Chirp Connect iOS SDK

Getting Started

Step 1 - Import the SDK into your project by dragging and dropping the .framework file into your Xcode project.

“Set ‘Copy items if needed’ if the framework is not already within your project folder.”

Step 2 - Add framework to Embedded Binaries.

Go to the Project Settings, under the General tab, and the Connect framework to the Embedded Binaries.

Step 3 - Add the microphone privacy statement. This text is displayed when your app first launches and asks the user for microphone permission, and should describe why you are requesting access to the microphone.

Under the Info tab in the Project Settings, add a Custom iOS Target Property called Privacy - Microphone Usage Description.

Step 4 - Disable Bitcode for the Connect SDK.

Under the Build Settings tab in the Project Settings, under Build Options, set Enable Bitcode to No.

Now for the code…

Step 5 - Include the SDK and its associated licence header:

#import <ChirpConnect/ChirpConnect.h>
#import "Licence.h"

And instantiate the SDK with your own app key and secret:

self.connect = [[ChirpConnect alloc] initWithAppKey:TEST_APP_KEY
                                     andSecret:TEST_APP_SECRET];

Next we have to configure the SDK by setting the licence string.

Your default licence is retrieved via the Chirp Admin Centre API, allowing it to be updated over-the-air.

[self.connect getLicenceStringWithCompletion:^(NSString * _Nullable licence, NSError * _Nullable error) {

    // set the licence
    NSError *licenceError = [self.connect setLicenceString:licence];

    // start the SDK
    NSError *startError = [self.connect start];

}];

Alternatively, your licence can be set without making a network call (completely offline) if you have been provided a licence file.

// set the licence
[self.connect setLicenceString:<YOUR LICENCE STRING>];

// start the SDK
NSError *error = [self.connect start];

You are now ready to send and receive data. First we will generate some random data to send, and send it using the SDK. When the send: method is called, Connect will encode the data and send it out through the device’s loudspeaker.

NSData *data = [self.connect randomPayloadWithLength:self.connect.maxPayloadLength];
NSError *error = [self.connect send:data];

To receive this data on a second device, simply implement the received: callback block:

[self.connect setReceivedBlock:^(NSData * _Nonnull data) {
    NSLog(@"received %@", data);
}];

You are now ready to start using Connect in your own application. For more advanced features, please look at the ChirpConnect/ChirpConnect.h header file, which lists the complete set of available methods.

Getting Started (Swift)

Follow steps 1 - 4 above.

Step 5 - Add framework to Linked Frameworks and Libraries.

Go to the Project Settings, under the General tab, and the Connect framework to the Linked Frameworks and Libraries.

Step 6 - Add a bridging header to the framework.

Add a new Objective-C file to your Swift project, Xcode will prompt if you want to configure your project with a bridging header. Press yes. Once the bridging header is added to your project, you can delete the Objective-C file if you want to.

Inside the bridging header add the following line, this now makes the Chirp Connect framework available throughout your project’s Swift files.

#import <ChirpConnect/ChirpConnect.h>

Step 7 - Instantiate the SDK with your own app key and secret:

let connect: ChirpConnect = ChirpConnect(appKey: TEST_APP_KEY, andSecret: TEST_APP_SECRET)

Next we have to configure the SDK by setting the licence string.

Your default licence can be retrieved over-the-air.

connect.getLicenceString {
  (licence: String?, error: Error?) in
  if error == nil {
    if let licence = licence {
      connect.setLicenceString(licence)
      connect.start()
    }
  }
}

Alternatively, your licence can be set without making a network call (completely offline) if you have been provided a licence file.

let licenceError: Error = connect.setLicenceString(<YOUR LICENCE STRING>)
let startError: Error = connect.start()

You are now ready to send and receive data. First we will generate some random data to send, and send it using the SDK. When the send: method is called, Connect will encode the data and send it out through the device’s loudspeaker.

let data: Data = connect.randomPayload(withLength: UInt(connect.maxPayloadLength))
connect.send(data)

To receive this data on a second device, simply implement the received: closure:

connect.receivedBlock = {
  (data : Data) -> () in
  if let data = data {
    print(String(data: data, encoding: .ascii))
    return;
  }
}

You are now ready to start using Connect in your own application. For more advanced features, please look at the ChirpConnect/ChirpConnect.h header file, which lists the complete set of available methods.