Link Search Menu Expand Document

Obtaining and Installing

Table of contents
  1. Obtaining and Installing
    1. Downloads location
    2. Installing
      1. Android
      2. Browser
      3. iOS
    3. Initializing
      1. Android
      2. Browser
      3. iOS

Downloads location

The most recent version of the Android, iOS and Browser SDKs can be downloaded here

Installing

Android

Below is a routine for getting the Android SDK installed in an application.

  • Place the SDK aar into your application libs directory.
  • Add these lines inside the dependencies in the app’s build.gradle file with the actual SDK aar file name instead uSDK-android-7.x.yy.aar:
dependencies {
    ...
    // The uSDK itself
  implementation(name: 'uSDK-android-7.x.yy', ext: 'aar')
   
   // The uSDK dependencies
  implementation "com.google.android.gms:play-services-location:18.0.0"
  implementation "com.google.android.gms:play-services-ads-identifier:18.0.0"
  implementation "com.android.support:appcompat-v7:28.0.0"
}

Please note that the version of the play-services and appcompat dependencies were actual for the time of writing of this documentation. The actual versions may be different in the future.

Please also make sure that the following permission is listed in the Android manifest file:

<uses-permission android:name="android.permission.INTERNET"/>

The uSDK needs the permission to be able to contact the cAPI / SplitSDK Server at runtime.

You may need to add the libs directory as repository in the app’s build.gradle file if you have not used manual linking before:

repositories {
    flatDir {
        dirs 'libs'
    }
}

Browser

This is how the Browser uSDK is integrated with a merchant web site.

  • Extract the archive downloaded
  • Place the uSDK .js file into under a web server
  • Include the .js file in an .html page (use the actual file name downloaded instead of usdk-browser-7.x.yy.js though)
<script src="/usdk-browser-7.x.yy.js"></script>

iOS

Once the iOS SDK is downloaded the following steps need to be performed:

  1. Unzip the file downloaded in a temporary folder
  2. Copy the uSDK.xcframework directory into your project directory
  3. In Xcode, click on your project. Then click on the target you want to link to. Finally, click on Build Phases.
  4. Expand the Link Binary With Libraries section.
  5. Click the +
  6. Then click Add Other and choose Add Files
  7. Navigate to uSDK.xcframework directory
  8. Click Open

Initializing

The uSDK needs to be initialized before first use. Once initialized, the uSDK is ready to perform its authenticate method. This section shows how to initialize the uSDK.

Android

SplitSdkClient splitSdkClient = new SplitSdkClientImpl();

InitializeSpec initializeSpec = new InitializeSpec(this /* Activity */);

splitSdkClient.initialize(initializeSpec, new InitializeCallback() {
    @Override
    public void onSuccess() {
        Log.i("APP", "splitSdkClient has been successfully initialized!");
    }

    @Override
    public void onFailure(Exception e) {
        Log.e("APP", "Failed to initialize splitSdkClient!", e);
    }
});

Browser

const splitSdkClient = new SplitSdkClientImpl();

const initializeSpec = new InitializeSpec();
const initializeCallback = {
    onSuccess: function () {
        console.log('splitSdkClient has been successfully initialized!');
        // now it is possible to call the `authenticate` method on the 'usdk' instance.
    },
    onFailure: function (error) {
        console.log('Failed to initialize splitSdkClient. Error: ', error);
    }
}
splitSdkClient.initialize(initializeSpec, initializeCallback);

iOS

class MyViewController: UIViewController {

    private var splitSdkClient: SplitSdkClient = SplitSdkClientImpl()

    override func viewDidLoad() {
        super.viewDidLoad()

        do {
            try splitSdkClient.initialize(spec: InitializeSpec(), callback: { result in
                switch result {
                case .success:
                    print("splitSdkClient has been successfully initialized!")
                    break
                case .failure(let error):
                    print("Failed to initialize splitSdkClient: \(error)")
                }
            })
        }
        catch {
            print("Error during initializating splitSdkClient: \(error)")
        }
    }
}