Transition guide for the Chirp Connect iOS SDK (v2 to v3)

Overall changes

  • The SDK no longer has an online mode for storing JSON data on the Chirp API. Accordingly fetchAssociatedDataWithCompletion and createChirpWithAssociatedData are not migrated to v3 SDKs.
  • The SDK can now work completely offline if you have a licence file.
  • Chirp with associated data has been removed and is no longer available.
  • The v2 Chirp ‘identifier’ is now referred to as a ‘payload’ and it is represented by NSData. The payload can have a dynamic length with a maximum length defined by your protocol.

Interface changes

The SDK init: method is unchanged between v2 and v3, as are the dependencies. See our iOS Getting Started guide for a quick description of setting up the iOS SDK in your own project.

Sending data now uses NSData, instead of NSString / ‘identifiers’ to represent your data:

v2:

Chirp *chirp = [[Chirp alloc] initWithIdentifier:@"abcde12345"];
[chirp chirpWithCompletion:^(Chirp *chirp, NSError *error)
 {
     NSLog(@"Completion: %@", chirp.identifier);
     if (error)
     {
         NSLog(@"ERROR: %@", error);
     }
 }];

You may notice that the v3 send: method no longer has a completion handler. All notifications of SDK state (sending data, sent data, receiving data, received data) now use separate blocks in v3, making it easy to update your app’s UI in response to Chirp SDK state changes:

v3 Sending notification

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

v3 Sent notification

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

v3 Receiving notification

[self.connect setReceivingBlock:^(void)
{
    NSLog(@"Receiving...");
}];

Receiving data now also references NSData, instead of NSString / ‘identifiers’ to represent your data:

v3 Received data notification

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

v2

[[ChirpSDK sdk] setChirpHeardBlock:^(Chirp *chirp NSError *error)
{
  if (error)
  {
    NSLog(@"An error occurred: %@", error);
  }
  else
  {
    NSDictionary *data = chirp.data;
    NSLog(@"Got chirp with identifier %@, data %@", chirp.identifier, chirp.data);
  }
}];