Installation
The iOS User.com SDK should be installed or updated using CocoaPods, a dependency manager Swift projects. CocoaPods provides added simplicity for integration and updating. We fully support Swift and Objective-C projects.
- Step 1. Install CocoaPods
Before beginning this process please ensure that you are using Ruby version 2.0.0 or greater.
To get started simply run the following command in your terminal:
$ sudo gem install cocoapods
More information about installation process can be found in Getting Started Directions on CocoaPods.org. If you have any issues regarding CocoaPods additional help can be found in CocoaPods Troubleshooting Guide.
- Step 2: Constructing the Podfile
Now that you’ve installed the CocoaPods Ruby Gem, you’re going to need to create a file in your Xcode project directory named
Podfile
. The contents of the file should look like this:platform :ios, '11.0' use_frameworks! target 'YourApp' do pod 'UserSDK', :git => 'https://github.com/UserEngage/iOS-SDK' end
Please remember to replace
YourApp
with a name of your target in the contents ofPodfile.
- Step 3: Installing the SDK
To install the User.com SDK, navigate to the directory of your Xcode app project within your terminal and run the following command:
pod install
At this point you should be able to open the new Xcode project workspace created by CocoaPods. Remember to open Xcode project workspace instead of Xcode project!
- Step 4. Initialize SDK in your app
To initialize User.com SDK, you need to add the following line of code to the top of your AppDelegate.swift file:
import UserSDK
To initialize SDK in your app add line from below:
#import <UserSDK/UserSDK-Swift.h>
Then initialize User.com builder with your SDK API key, context and base URL. It will initialize User.com instance.
You can generate API key in User.com web panel, as described in getting started section.
Within your AppDelegate.swift file, add the following snippet within your
method:application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
let sdk = UserSDK( application: UIApplication.shared, apiKey: "<api_key>", baseURL: "<your_domain>.user.com", shouldTrackActivities: true)
Within your AppDelegate.m file, add the following snippet within our
method:- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
UserSDK *sdk = [[UserSDK alloc] initWithApplication:[UIApplication sharedApplication] apiKey:@"<api_key>" baseURL:@"<your_domain>.user.com" shouldTrackActivities:YES];
Be sure to update
api_key
andyour_domain
with the correct values from your App Settings page. If you want to track you client’s mobile view screens activities remember to setshouldTrackActivities
to true.