/LotameDMP-IOS

This open source library can be leveraged by Lotame clients to collect data from within their iOS applications.

Primary LanguageSwiftMIT LicenseMIT

LotameDMP-IOS

This open source library can be leveraged by Lotame clients to collect data from within their iOS applications.

Version License Platform

Requirements

LotameDMP requires Xcode 7 and at least iOS 8.0. It will work with swift or Objective-C.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

Embedded frameworks require a minimum deployment target of iOS 8 or OS X Mavericks (10.9).

CocoaPods

CocoaPods is a dependency manager for Cocoa projects.

CocoaPods 0.38.2 is required to build LotameDMP. You can install it with the following command:

$ gem install cocoapods

To integrate LotameDMP into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

pod 'LotameDMP', '~> 3.0'

Then, run the following command:

$ pod install

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>

Usage

LotameDMP must be imported by any file using the library.

import LotameDMP

or for objective-c

#import "LotameDMP-Swift.h"

Initialization

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)

Send Behaviors

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
	}
}

Get Audience Data

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.

Start a New Session

To indicate that a new session has started, use the following command:

DMP.startNewSession()

or for objective-c

[DMP startNewSession];

License

LotameDMP is available under the MIT license. See the LICENSE file for more info.