iOS SDK Integration
The minimal iOS deployment target version is 11.
The programming language is Swift.
Before you start
Make sure you've obtained a token, server URL, and auth key from credolab
1. Declare dependencies
See this page for details on installing CocoaPods and creating your first pod file if you haven't already.
Now, modify your pod file
source 'https://token:[email protected]/basic/credolab/proxyen-sdk/cocoapods/index.git'
target 'YourApplication' do
pod 'CredoAppCore', '~> X.Y.Z'
pod 'CredoAppCalendarEvents', '~> X.Y.Z'
pod 'CredoAppCalendarReminders', '~> X.Y.Z'
pod 'CredoAppContacts', '~> X.Y.Z'
pod 'CredoAppMusic', '~> X.Y.Z'
pod 'CredoAppMedia', '~> X.Y.Z'
pod 'CredoAppApplication', '~> X.Y.Z'
pod 'CredoAppBehavioral', '~> X.Y.Z'
# Optional: if you want to use logging plugin
pod 'CredoAppLogging', '~> X.Y.Z'
pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '7.23.0'
End
Note
Please, replace X.Y.Z with module versions from SDK Versions page.
The final result should look like this:pod 'CredoAppModule', '~> 1.0.0'
Once added, the cocoa pods tool will download the dependency to the Pods directory in your project and update the Podfile.lock
after running the following command:
pod install
2. Declare permissions
Please declare permissions according to the "permissions" in Modules section
Enable "Keychain Sharing"
To enable sharing the Device ID across apps and ensure it survives app reinstalls, we recommend additionally configuring "Keychain Sharing" in the app.
- Add
com.credolab
to its list of Keychain Groups:
- Check that added value is reflected in the entitlements file:
$(AppIdentifierPrefix)com.credolab
- Add the key
AppIdentifierPrefix
with the string value$(AppIdentifierPrefix)
to your app'sInfo.plist
3. Build and use CredoAppService
To start, you need to add the following snippet to your code
// if you use BehavioralModule
// credolab recommends to use logging in behavioral module
BehavioralModule.setLogger(plugin: LoggingPlugin())
// run can tracking in any place in your code
BehavioralModule.startTracking()
let credoAppService = CredoAppService.Builder()
.addModule(BehavioralModule())
.addModule(CalendarEventsModule())
.addModule(CalendarRemindersModule())
.addModule(ContactsModule())
.addModule(MediaModule())
.addModule(MusicModule())
.addModule(ApplicationModule())
.addPlugin(LoggingPlugin())
.build()
// stop tracking on a particular screen or app condition
BehavioralModule.stopTracking()
Note
Please refer to
BehavioralModule
section for additional information about module integration.
Application module
To integarte
CredoAppApplication
module, the initial step involves adding URL Schemas into theInfo.plist
file within your project (maximum 50 schemas are allowed).Below is a list of common app schemas along with a detailed guide on how to declare them in the
Info.plist
file.🦉iOS Common URL schemasOpen Recipe
Now, use the service
let credoAppResult = credoAppService.collect()
switch credoAppResult {
case .success(let value):
log(value)
case .error(let errorCode, let errorMsg):
log("Err: \(Date().timeIntervalSince1970); code - \(errorCode); msg - \(errorMsg);")
}
Note
Remember that you always must call
collect
method on a background threadDispatchQueue.global(qos: .background).async
.If
collect
method is successful then dataset is returned.
Behavioral data is cleared on
collect()
method callOnce
collect()
method is calledBehavioralModule
clears its data stored on user the device.Thus, for data consistency, our strong recommendation is to call the method only once: at the end of the user flow.
4. Upload from an iOS Device (Testing purposes only)
Direct Upload Note:
In a production environment, datasets should only be uploaded via your organization's proxy server.
For testing, integration, or generating insights, you may use the following code snippet:
If you have any further questions, please do not hesitate to contact us.
Video Tutorials
Core Module Integration Tutorial
Optional Modules Integration Tutorial
Behavioral Module Integration Tutorial
Next Steps
After successfully integrating our SDK, it is recommended to proceed with the following steps to utilise our platform effectively:
- Setting up your Reverse Proxy
- Uploading your Dataset. Once the server is configured, you can upload your dataset using the server address.
- Collecting your Dataset Insight or TruValidate(formerly known as iovation) Fraud Check. With the dataset uploaded, you can now get insights or perform TruValidate Fraud Checks to assess risk based on the device and transaction details provided.
Updated 24 days ago