Singular Fraud SDK - iOS

Requirements and Libraries

Add Singular and other necessary libraries into your application

  1. Download and unzip the SDK.
  2. Click on Your App Name > Add Files To <Your Project Name>.
  3. In the dialog, select Options > Create Groups and add the folder in which you unzipped the SDK.
  4. The following files should now be in your project: libSingular.a, Singular.h, SingularLinkParams.h, and Singular.js.
  5. Click on Your App Name > Build Phases and expand Link Binary With Libraries.
  6. Click on the + icon and add the following libraries:
    • libsqlite3.0.tbd
    • SystemConfiguration.framework
    • Security.framework
    • libz.tbd
    • AdSupport.framework
    • iAd.framework

If your build fails, add the directory where libSingular.a is located explicitly to your project's "Library Search Paths" (Build Settings > Search Paths > Library Search Paths).

Initialization and Session Tracking

Objective-C

If your app is coded in Swift, review the "Using Swift" section for instructions on building a bridging header with sample code.

Import Singular class library by adding the following to your AppDelegate file:

#import "Singular.h"

For most apps, add the following to the applicationDidBecomeActive function:

- (void)applicationDidBecomeActive:(UIApplication *)application 
{ 
    [Singular startSession:@"yourAPIKey" withKey:@"yourSecret"];
}

Swift

Swift is designed to work with Apple's Cocoa and Cocoa Touch frameworks and the large body of existing Objective-C code written for Apple products. In order to utilize Objective-C code in a Swift Application, a bridging header must be created.

Create Bridging Header

If you are developing with Swift follow these instructions to build an Objective-C bridging header file.

Session Management

Import Singular class library by adding the following to your "*-Bridging-Header.h" file

//  *-Bridging-Header.h

#import "Singular.h"

Add the following to the applicationDidBecomeActive function:

func applicationDidBecomeActive(_ application: UIApplication) {
        Singular.startSession("yourAPIKey", withKey: "yourSecret")
}
Was this article helpful?
0 out of 0 found this helpful