Questions? Feedback? powered by Olark live chat software

iOS SDK

The iOS SDK collects data from iOS mobile applications and transmits the collected data to Simility’s software. Simility provides a zip file, which you must include in your iOS application project.

In the app runtime, when the SDK is invoked, the required data is collected and sent to the Simility software asynchronously in the background thread without affecting the user interface operations.

Refer to the following sections to learn how to configure the iOS SDK in the Objective-C-based application and in the Swift-based application.

Configuring the SDK in the Objective-C-based Application

In the Objective-C-based Application, you can configure the SDK by adding header and library files, and also using the CocoaPods file.

Configuring by adding Header and Library Files

  1. Download the zip file and extract it.
  2. In Xcode, create a new project or open an existing project.
  3. Drag the extracted files to the Supporting Files folder on the left pane. The Choose options for adding these files dialog box opens.
  4. Select Copy items if need, and click Finish.
  5. Import the SimilityRecon header file and add the code for calling the Simility API (refer the sample code below).
  6. Build and run the application.

Configuring using the CocoaPods file

  1. Execute the following command to add the POD repo.
    pod repo add SimilityRecon-iOS https://github.com/Simility/SimilityRecon-iOS-Specs.git
  2. In the POD file, add the following line:
    pod ‘SimilityRecon-iOS’, ‘~> 1.614’
  3. Install POD.
  4. Import the SimilityRecon header file and add the code for calling the Simility API (refer the sample code below).
  5. Build and run the application.

Sample Code

#import "ViewController.h"
// Include Simility Header file
#import "SimilityRecon.h"

@interface ViewController ()

@end

@implementation ViewController

  - (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    // Construct a valid SimilityContext object
    SimilityContext *similityContext = [[SimilityContext alloc] init];
    [similityContext setCustomerId:@"5e295f6c-5fd2-11e7-907b-a6006ad3dba0"]; // replace  with unique identifier assigned by Simility. This will be provided to you during signup.
    [similityContext setSessionId:@"your.session.id.variable"]; //replace with sessionID variable
    [similityContext setUserId:@"your.user.id.variable"]; //replace with userID variable
    [similityContext setEventtypes:@"payment_view"]; // Comma separated snake_case string of action/event which is associated with this activity/view.
    [similityContext setZone:@"us"]; // Default: "us". If data regulatory compliance requires your data to be hosted in Europe datacenters, please specify zone as "eu" 

    // Execute SimilityScript
    [[SimilityScript sharedInstance] execute:similityContext];
  }

@end

Configuring the SDK in the Swift-based Application

  1. Download the zip file and extract it.
  2. If the Object-C bridging header file does not exist in your project, create a dummy Objective-C file and place the file along with the extracted files.
  3. On the left pane, in your project, create a new folder with name, Supporting Files.
  4. Drag the extracted files along with the dummy Objective-C file to the Supporting Files folder. The Choose options for adding these files dialog box opens.
  5. Select Copy items if need, and click Finish. A dialog box opens asking whether to create Objective-C bridging header or not.
  6. Click Create Bridging Header.
  7. Delete the dummy Objective-C file from the Supporting Files folder.
  8. Open the ViewController file of the view from which you want to capture the data and add the following import statement.
    #import "SimilityBeacon.h"
  9. In the ViewController file, create the SimilityContext Class with necessary methods and then create the SimilityScript Class.
  10. Build and run the application.

Sample Code

// Include Simility Header File in your Objective C Bridging-Header.h
#import "SimilityBeacon.h"

import UIKit

class ViewController: UIViewController {
  override func viewDidLoad() {
    super.viewDidLoad()
    // Construct a valid SimilityContext
    let similityContext =  SimilityContext()
    similityContext.customerId = "5e295f6c-5fd2-11e7-907b-a6006ad3dba0" // replace  with unique identifier assigned by Simility. This will be provided to you during signup.
    similityContext.sessionId = "your.session.id.variable" //replace with sessionID variable
    similityContext.userId = "your.user.id.variable" //replace with userID variable
    similityContext.eventTypes = "payment_view" // Comma separated snake_case string of action/event which is associated with this activity/view.
    similityContext.setZone("us") // Default: "us". If data regulatory compliance requires your data to be hosted in Europe datacenters, please specify zone as "eu" 

    // Execute SimilityScript 
    SimilityScript.execute(similityContext)
  }
}

SimilityContext Class

Use the class to create a Simility context with required methods and pass it to the SimilityScript class as a parameter.

In the SimilityContext class, you can add the following methods. These methods are applicable for Object-C-based applications and Swift-based applications as well.

+ setCustomerId Method
Description Sets the customer ID.
Syntax
- (void) setCustomerId:&ltcustomerId>
Parameters
Name Type Description
customerId String Specify the UUID provided by Simility.
Example
//Objective-C-based application
[similityContext setCustomerId:@"5e295f6c-5fd2-11e7-907b-a6006ad3dba0"];

//Swift-based application
similityContext.customerId = "5e295f6c-5fd2-11e7-907b-a6006ad3dba0"
+ setEventTypes Method
Description Sets the type of the event.
Syntax
- (void) setEventTypes:<eventTypes>
Parameters
Name Type Description
eventTypes String Specify the event or action that you want to associate with the JavaScript. You can specify multiple values separated with a comma.
Example
//Objective-C-based application
[similityContext setEventtypes:@"payment_view"];

//Swift-based application
similityContext.eventTypes = "payment_view"
+ setSessionId Method
Description Sets the session ID.
Syntax
- (void) setSessionId:<sessionId>
Parameters
Name Type Description
SessionId String Specify a unique session ID assigned to the user sessions when users accessed your application.
Example
//Objective-C-based application
[similityContext setSessionId:@"your.session.id.variable"];

//Swift-based application
similityContext.sessionId = "your.session.id.variable"
+ setZone Method
Description Sets the zone where your data centers are hosted.
Syntax
- (void) setZone:&ltzone>
Parameters
Name Type Description
zone String Specify the zone where your datacenters are hosted.
Example
//Objective-C-based application
[similityContext setZone:@"us"];

//Swift-based application
similityContext.setZone("us")

SimilityScript Class

Use the class to execute the created Simility context.

+ execute Method
Description Executes the specified Simility context.
Syntax
+ (void) execute:&ltsimilityContext>
Parameters
Name Type Description
similityContext Context Specify the name of the Simility context that you want to execute.
Example
//Objective-C-based application
[SimilityScript execute:similityContext];

//Swift-based application
SimilityScript.execute(similityContext)