This open source library can be leveraged by Lotame clients to collect data from within their iOS applications.
LotameDMP requires Xcode 8 and at least iOS 8.0. It will work with Swift or Objective-C.
To run the example project, clone the repo, and run pod install from the Example directory first.
Embedded frameworks require a minimum deployment target of iOS 8 or OS X Sierra (10.12).
CocoaPods is a dependency manager for Cocoa projects.
CocoaPods 1.2.1 is required to build LotameDMP. You can install it with the following command:
$ gem install cocoapodsTo integrate LotameDMP into your Xcode project using CocoaPods, specify it in your Podfile:
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
target "YourTargetName" do
pod 'LotameDMP', '~> 4.1'
endNote: Make sure to update the name of your target
Then, run the following command:
$ pod repo update
$ pod installNote: Make sure to update your local CocoaPod repo if you haven't done so recently.
Close your .xcodeproj file, and open the generated .xcworkspace.
Add the following elements to your project's Info.plist file to configure ATS:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>crwdcntrl.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>LotameDMP must be imported by any file using the library.
import LotameDMPor for Objective-C
#import "LotameDMP-Swift.h"LotameDMP is a singleton that must be initialized with a client id once before using it. Run the following command before executing any other calls:
DMP.initialize("YOUR_CLIENT_ID_NUMBER")or for Objective-C
[DMP initialize:@"YOUR_CLIENT_ID_NUMBER_"];The initialize call starts a new session and sets the domain and protocols to their default values (https://*.crwdcntrl.net)
Behavior Data is collected through one of the add commands:
DMP.addBehaviorData("value", forType: "type")
DMP.addBehaviorData(behaviorId: 1)
DMP.addBehaviorData(opportunityId: 1)or for Objective-C
[DMP addBehaviorData:@"value" forType: @"type"];
[DMP addBehaviorDataWithBehaviorId: 1];
[DMP addBehaviorDataWithOpportunityId: 1];It must be sent to the server to record the behaviors:
DMP.sendBehaviorData()or for Objective-C
[DMP sendBehaviorData];If you're interested in the success or failure of sending the data, use a completion handler:
DMP.sendBehaviorData(){
result in
if result.isSuccess{
//Success
} else{
//Failure
}
}or for Objective-C
[DMP sendBehaviorDataWithHandler: ^(NSError * _Nullable error){
if (error != nil){
//Failure
} else {
//Success
}
}];Get the audience data with the following command:
DMP.getAudienceData{
result in
if let profile = result.value{
//Successful request, use LotameProfile object
} else {
//result.error will contain an error object
}
}or for Objective-C
[DMP getAudienceDataWithHandler:^(LotameProfile * _Nullable profile, BOOL success) {
if (success) { //Check for success
//Successful request, use LotameProfile object
}
}];The completion handler uses a Result enum to indicate success or failure.
To indicate that a new session has started, use the following command:
DMP.startNewSession()or for Objective-C
[DMP startNewSession];Version 4.0.0 updates the code to Swift 3, since Xcode 8.3.2 dropped support for Swift 2.3.
The previous version of Lotame 3.0.1 had a dependency on Alamofire 2.0. This dependency has been updated to Alamofire 4.4. If your project leveraged Alamofire, please see their migration guide for updating your network calls.
Note to code maintainers: when changing the version, make sure to update these 3 locations:
LotameDMP.podspec- Git tag
sdkVersioninDMP.swift
LotameDMP is available under the MIT license. See the LICENSE file for more info.