Setting up your app

🔩 Minimum requirements

First, check out if you fulfill 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 Inloco SDK. CocoaPods manages library dependencies for your Xcode projects; to learn more, check its installation guide.

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

Shell
Shell
$ pod init

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

Podfile
Podfile
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
pod 'InLocoEngage-iOS-SDK', '~> 5.5.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 Inloco 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 Inloco to use the current connected WiFi to improve visit detection and location accuracy.

Add config file in your project

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

🧙♂Tip: There is a button on integration wizard where you can download InLocoOptions.plistfile with your app_id already filled.

InLocoOptions.plist
InLocoOptions.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 replace YOUR_APP_IDwith the identifier of the application you created on your dashboard. Click here if you don't know your App ID or if you don't know what App ID is.

The complete list of possible customization keys is shown below.

Key

Description

Type

Required

applicationId

The Inloco 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

In the application:didFinishLaunchingWithOptions: method of your AppDelegate file, insert the code below to initialize the Inloco SDK.

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

If the SDK was initialized properly, your console output will look like the one below. The table identifies the main elements required for Inloco to work properly. When a requirement is not met, a description is shown with information regarding what this requirement enables and what must be done for it to be satisfied. In the below example, the device is ready to receive push notifications, but won't work with data integrations.

Shell
Shell
// Printed if logs are enabled.
InLoco: In Loco Common SDK v5.5.1 is running.
InLoco: In Loco Location SDK v5.5.1 is running.
InLoco: In Loco Engage SDK v5.5.1 is running.
InLoco: The installation identifier is <INSTALLATION-ID>.

Testing

After integrating the SDK, the wizard will wait for an event to be sent in order to validate that the integration was successful.

👮♂ Request runtime permissions

The steps above will initialize the SDK, but your application still needs to request the location permissions to 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 Inloco SDK makes use of Apple's Visits Location Service, which requires the Always authorization. Not being able to acquire this authorization may greatly reduce the frequency of location-based features, such as pushes. More about the Visits Location Service can be found here.

It is extremely important that the user is asked for location permissions and that the app has a relevant reason to do so.