iOS SDK Integration
A high-level guide for installing Forter's mobile SDK for native iOS Apps
This guide is for installing Forter's iOS SDK for native iOS applications! Note that you'll need a Forter portal account and your unique Forter credentials to complete an SDK integration. The steps below outline the high-level integration flow.
Step 1: Install the SDK 

Forter's iOS SDK is distributed both on Swift Package Manager and CocoaPods.
Swift Package Manager
- Go to the
Package Dependencies
tab of your Project Navigator then click the+
button and add Forter's bitbucket link

- Alternatively, if you have
Package.swift
dependencies file, you can add the SDK directly to the dependencies array.
dependencies: [
.package(url: "<forter ios bitbucket link>.git", .upToNextMinor(from: "2.2.0"))
]
CocoPods
- Make sure your your Podfile includes the
use_frameworks!
flag. - Add the ForterSDK Pod to the Podfile next to the rest of the frameworks you're using:
pod 'ForterSDK', :git => <bit bucket forter ios link>.git'
- Run the
pod install
command
Step 2: Initiate the SDK 

Initialize your SDK from the iOS Application Delegate. This will ensure that it loads correctly when the app is active. For more information on the app delegate, please see the Official iOS Developer Documentation
- Import the SDK
Swift
import ForterSDK
Objective-C
#import <ForterSDK/ForterSDK.h>
- Use your siteId found in your dedicated Forter portal from the appropriate environment and then initiate the SDK using the following command:
Swift
ForterSDK.setupWithSiteId("your_forter_site_id")
Objective-C
[ForterSDK setupWithSiteId:@"your_forter_site_id"];
- Add Callbacks from your Application Delegate
- When receiving messages from your Application Delegate, you'll call specific Forter SDK methods when your iOS Application becomes active.
Please make sure to call ALL the AppDelegate callbacks
Step 3: Provide Unique Identifiers 

Forter's SDK requires a unique mobile device identifier to link the activity and behavioral data collected by the SDK to the specific device and user. This identifier should be:
- specific to each device
- Does not mutate from a user's app session
- PII compliant.
Forter recommends using the iOS IDFV (Identifier For Vendor). To set the mobileUID use the following command:
Swift
ForterSDK.sharedInstance().setDeviceUniqueIdentifier(UIDevice.current.identifierForVendor.uuidString)
Objective-C
[[ForterSDK sharedInstance] setDeviceUniqueIdentifier:UIDevice.currentDevice.identifierForVendor.UUIDString];
important The mobileUID should be sent in the [backend API requests](#Include-mobileUID-in-backend-and-Forter-API-requests) as the value for the connectionInformation.forterMobileUID
key. backend API requests
Casing While Forter's system has no casing preference, the
mobileUID
generated via the SDK must match the casing of the mobileUID that is passed to the Validation API at the time of transaction in order for Forter's system to correctly connect the SDK data to the backend, Validation API's data.
Step 4: Send Event Data 

In order to keep our SDK as lightweight as possible, Forter SDK does not collect navigation and custom activity events by default. These events should be called on relevant screens and actions. For instance, if a user searches for an item in the app and then proceeds to select a specific color, size, customization, a navigation event should be called with the FTRSDKNavigationTypeSearch
value. The method and type should only be called once and no additional details like size, color, brand, etc. need to be included.
Forter provides 2 methods for adding custom event:
- TrackAction - Actions performed by the user such as: removing items from cart, adding items to cart, logging into account, attempting to initiate a payment. The data included in this method can be a String or a Dictionary.
[[ForterSDK sharedInstance] trackAction:FTRSDKActionTypeAddToCart
withMessage:@"yellow bb shirt-xL"];// item id in your system
- TrackNavigation - Events where there's a context change like: navigating to a different product page or search result.
[[ForterSDK sharedInstance] trackNavigation:@"SingleItemViewController" withType:FTRSDKNavigationTypeProduct];
Step 5: Test/View your mobile events 

Once you've integrated the mobile SDK in sandbox (using your sandbox SiteId), you can look up events being passed to Forter for a specific mobileUID using our Sandbox Mobile Events Viewer. This gives developers visibility into how Forter is receiving and storing mobile events.
Step 6: Include mobileUID in backend and Forter API requests 

Send the mobileUID generated by the Forter SDKs to your backend when an order is placed via your native mobile application.
This will allow Forter to connect behavioral and cyber data collected on the mobile applications to the order data sent from your backend. Merchants are in charge of how the mobileUID is passed and most will pass it securely via API request headers. In the case of native mobile app orders, make sure that the following fields are populated:
- orderType: "MOBILE", "iOS", or "ANDROID" depending on your OS (mobile can be used for either OS)
- forterMobileUID: This should be populated instead of the
forterTokenCookie
if your app is fully native including your checkout page. If you use a webview for the checkout page, please review our Webview Integration. - mobileAppVersion: should reflect the version of the app the user is on
Example iOS Request
{
"orderId": "Example_order_fdse0rr489",
"orderType": "iOS",
"timeSentToForter": 1415287568000,
"checkoutTime": 1415273168,
"connectionInformation": {
"customerIP": "107.57.208.5",
"userAgent": "testStore 18.4.1 rv:184100001 (iPhone; iOS 12.4.1; en_US; iPhone10,3)",
"forterMobileUID": "6A9798AG16FF41F7B6B9878DD488ADD5",
"mobileAppVersion": "18.4.1"
},
"totalAmount": {
"amountUSD": "99.95"
}
...
}
Step 7: Deploy to Production 

Merchants are in complete control of how and when they deploy Forter's SDK into their production environment. You'll work closely with your implementation team to ensure a seamless deployment of our SDK within your mobile app versions.
Updated 6 months ago