Fraud iOS SDK

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 :apple:

Forter's iOS SDK is distributed both on Swift Package Manager and CocoaPods.

Swift Package Manager

Xcode
  • Navigate to File > Add Packages, paste Forter's distribution link (can be retrieved from the portal) to the search controller on the top right and press Add Package.
  • Select the ForterSDK product and press Add Package
Package.swift
  • Alternatively, if you have Package.swift dependencies file, you can add the SDK directly to the dependencies array.
dependencies: [
    .package(url: "<forter-distribution-link>", .upToNextMajor(from: "2.3.0"))
]
  • Then add ForterSDK to the dependencies array of the target:
targets: [
        .target(
            name: "MyTarget",
            dependencies: [
                .product(name: "ForterSDK", package: "forter-ios-sdk")
        ),

CocoaPods

  • Make sure your your Podfile includes the use_frameworks! flag.
  • Add the ForterSDK pod to the Podfile next to the rest of pods used in your app:
pod 'ForterSDK', :git => <forter-distribution-link>'
  • Run the pod install command

Step 2: Initiate the SDK :sparkles:

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

  1. Import the SDK

Swift

import ForterSDK
#import <ForterSDK/ForterSDK.h>
  1. Setup the SDK on app launch using your siteId found in Forter portal for the appropriate environment.

Swift

ForterSDK.setupWithSiteId("your_forter_site_id")
[ForterSDK setupWithSiteId:@"your_forter_site_id"];
  1. 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.
  • :fire: Please make sure to call ALL the AppDelegate callbacks :fire:

Step 3: Provide Unique Identifiers :person-with-pouting-face:

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:

  1. specific to each device
  2. Does not mutate from a user's app session
  3. 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)
[[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 :department-store:

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:

  1. 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
  1. 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 :chart-with-upwards-trend:

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 :white-check-mark:

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:

  1. orderType: "MOBILE", "iOS", or "ANDROID" depending on your OS (mobile can be used for either OS)
  2. 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.
  3. 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 :rocket:

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.


What’s Next