Native Apps
The DataSapien Mobile SDK is available for iOS and Android native apps. Android and iOS SDKs provide the same set of functionality.
iOS
The iOS SDK is available as an SPM package that you can reference in an Xcode project. DataSapien iOS Mobile SDK is developed using Swift.
Prerequisites
Before getting started, ensure your development environment meets the following prerequisites:
- Xcode 14.1-14.3.1 with a target of iOS 11.0 or higher
- Reflection is enabled in your project. The Swift SDK uses reflection to determine your model's properties. Your project must not set
SWIFT_REFLECTION_METADATA_LEVEL = none
, or the SDK cannot see properties in your model. Reflection is enabled by default if your project does not specifically set a level for this setting. - Set up a physical Apple device or use a simulator to run your app.
Step 1: Register DataSapien project (Beta)
Before you can add Mobile SDK to your iOS app, you need to request an enterprise project to connect to your app.
Step 2: Add a DataSapien configuration file (Beta)
To use Mobile SDK in your iOS app, you need to register your app with your DataSapien Enterprise project. Configuration file contains:
- Enabled Module List
- License
- Create DS-Info.plist to obtain your Apple platforms config file (DS-Info.plist).
- Move your config file into the root of your Xcode project. If prompted, select to add the config file to all targets.
If you have multiple bundle IDs in your project, you must associate each bundle ID with the configuration file.
Step 3: Add DataSapien iOS SDK to your app
SPM Installation
Swift Package Manager is available for DataSapien SDK. Framework can be added as a dependency by using SPM. Details blow:
- Add Datasapien SPM dependency to the project.
- Select target.
- Build the project.
Step 4: Initialize SDK in your app
- To initialize SDK you must modify your Application Delegate. Inside the application
didFinishLaunchingWithOptions
add the following code to import the Mobile SDK:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let config = DataSapienConfig.Builder().setAuth("Auth_url",
"client_id",
"client_secret",
"scope")
.sethostUrl("host_url")
.build()
DataSapien.initialize(dataSapienConfig: config)
}
Step 5: Initial Calls
- After initializtion of the SDK. Medata - Exchange - Journeys - Questions and native meData collection can be fetched and called. 1.a) Medata Definitions are the building blocks of the platform. It needs to be fetched first. 1.b) After that exchange and journeys can be fetched. 1.c) Exchanges can have Q/A questions. Q/A questions can be fetched from getQuestionService 1.d) CollectAllNatives is for collecting native medata.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let config = DataSapienConfig.Builder().setAuth("Auth_url",
"client_id",
"client_secret",
"scope")
.sethostUrl("host_url")
.build()
DataSapien.initialize(dataSapienConfig: config)
dataSapienSetup()
}
func dataSapienSetup() {
DataSapien.getMeDataService().fetchMeDataDefinitions { medataDefinitions in
DataSapien.getJourneyService().fetchJourneys { journeys in
DataSapien.getExchangeService().fetchExchanges { exchanges in
DataSapien.getQuestionService().fetchQuestions { questions in
DataSapien.getMeDataService().collectAllNatives {
Logger.shared.log("✅ DataSapien Setup Complete", level: .debug)
}
} onError: { error in
Logger.shared.log("❌ Error in collectAllNatives: \(error)", level: .debug)
}
} onError: { error in
Logger.shared.log("❌ Error in fetchExchanges: \(error)", level: .debug)
}
} onError: { error in
print("❌ Error in Journeys")
}
} onError: { error in
Logger.shared.log("❌ Error in fetchMeDataDefinitions: \(error)", level: .debug)
}
}
Android
The Android SDK is available in Maven that you can reference in a Gradle based project. DataSapien Android Mobile SDK is developed using Kotlin.
Prerequisites
Before getting started, ensure your development environment meets the following prerequisites:
- Android Studio Bumblebee 2021.1.1 or higher.
- JDK 11 or higher.
- Kotlin Plugin for Android Studio, version 1.6.10 or higher.
- An Android Virtual Device (AVD) using a supported CPU architecture.
Additional documentation is available on request. Contact us for further information.
Step 1: Register DataSapien project (Beta)
Before you can add Mobile SDK to your Android app, you need to request an enterprise project to connect to your app. Visit TODO.
Step 2: Add a DataSapien configuration file (Beta)
To use Mobile SDK in your Android app, you need to register your app with your DataSapien Enterprise project. Configuration file contains:
- Enabled Module List
- License
- Create DS-Info.plist to obtain your Firebase Apple platforms config file (DS-Info.plist).
- Move your config file into the module (app-level) root directory of your app.
If you have multiple bundle IDs in your project, you must associate each bundle ID with the configuration file.
Step 3: Add DataSapien SDK to your app
If you want to import the SDK without using Maven you can import the framework manually. Details below:
- Download the latest SDK version.
- Extract the framework from the zip file.
- Copy DSSDK.aar file to your project’s
/lib
folder (if you don’t have it, create the folder first) - Add SDK to your application’s
build.gradle
:`
dependencies {
implementation files('libs/DSSDK.aar')
}
- Add Google Play Services to your build.gradle:
repositories {
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
implementation 'com.google.android.gms:play-services-ads-identifier:17.1.0'
}
Step 4: Initialize SDK in your app
- To initialize SDK you must modify your main Activity’s
onCreate()
method
import com.datasapien.ds
DS.connect(getApplicationContext(), "SDK_KEY_GOES_HERE", new DSConnectionListener() {
@Override
public void onConnectSuccess() {
this.onConnectSuccess();
}
@Override
public void onConnectFailure() {
this.onConnectFailure();
}
});