Obtaining and Installing
Table of contents
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 applicationlibs
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 ofusdk-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:
- Unzip the file downloaded in a temporary folder
- Copy the
uSDK.xcframework
directory into your project directory - In Xcode, click on your project. Then click on the target you want to link to. Finally, click on
Build Phases
. - Expand the
Link Binary With Libraries
section. - Click the
+
- Then click
Add Other
and chooseAdd Files
- Navigate to uSDK.xcframework directory
- 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)")
}
}
}