iOS

Minimum requirements

First, make sure your app fulfills the SDK minimum requirements.

Requirement

Version

XCode

9.0 or higher

Project target

iOS 9 or higher

For Swift projects

Swift 3.0 or higher

CocoaPods

1.2.0 or higher

Dependencies

Your application must use CocoaPods in order to install the Incognia SDK. CocoaPods manages library dependencies for your Xcode projects. To learn more, check out the installation guide.

Create a podfile if you don't have one by typing the following command:

Shell
Shell
$ pod init

Then, add the Incognia SDK pod to your project's Podfile.

Podfile
Podfile
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
pod 'Incognia', '~> 5.6.1'

Install the pod and open the .xcworkspace file to see the project in Xcode.

Shell
Shell
$ pod install --repo-update
$ open your-project.xcworkspace

Capabilities

The Incognia SDK uses the Access WiFi Information capability to improve visit detection and location accuracy. To enable it, in the Capabilities section of your app, enable the Access WiFi Information capability (XCode 10 and iOS 12+ only):

Note: From iOS 12, Apple added a new capability called Access Wifi Information. Adding this capability is highly recommended as it allows Incognia to use the current connected WiFi to improve visit detection and location accuracy.

Add config file in your project

The Incognia SDK initialization relies on the presence of an IncogniaOptions.plist file in your project. Please modify the applicationId field below and add it to your iOS project.

IncogniaOptions.plist
IncogniaOptions.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>applicationId</key>
<string>YOUR-APP-ID</string>
<key>logEnabled</key>
<true/>
<key>privacyConsentRequired</key>
<false/>
<key>locationEnabledByDefault</key>
<true/>
</dict>
</plist>

Note: Remember to replaceYOUR-APP-IDwith the identifier of the application that our team provided to your company.

The complete list of possible customization keys is shown below.

Key

Description

Type

Required

applicationId

The Incognia Application ID.

string

logEnabled

Whether logs are enabled.

boolean (true)

privacyConsentRequired

Whether the user needs to provide privacy consent for the SDK to be initialized.

boolean (false)

locationEnabledByDefault

Whether location is enabled by default during the SDK initialization.

boolean (true)

Initializing the SDK

Insert the code below into the application:didFinishLaunchingWithOptions: method of your AppDelegate file to initialize the Incognia SDK.

Swift
Objective-C
Swift
import Incognia
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
//Initializes the Incognia SDK
ICGIncognia.initSdk()
return true
}
}
Objective-C
#import "AppDelegate.h"
@import Incognia;
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Initializes the Incognia SDK
[ICGIncognia initSdk];
return YES;
}
@end

If the SDK was initialized properly, your console output will look like the one below.

Shell
Shell
// Printed if logs are enabled.
Incognia: Incognia Common SDK v5.6.0 is running.
Incognia: Incognia Location SDK v5.6.0 is running.
Incognia: The installation identifier is <INSTALLATION-ID>.

Request runtime permissions

The steps above will initialize the SDK, but your application still needs to request location permissions from the user in order to fully unlock the location capabilities of the SDK. We recommend that the permissions are requested as shown in the iOS documentation.

Attention: The Incognia SDK makes use of Apple's Visits Location Service, which requires the "Always" authorization. Not acquiring this authorization may greatly reduce the frequency of location-based features therefore it is extremely important that the user is asked for location permissions. More about the Visits Location Service can be found here.

What's next?

From here, you can either complete the full integration with our APIs by using the Installation ID or follow the steps to test the Incognia solution with the SDK-only integration. In this mode, you will receive access to a dashboard that displays Incognia's risk scores without needing to integrate the APIs.