Project initialization

Project settings

Mobile key

Add the following key to Info.plist file (String value) with the corresponding value (that you obtained when added your app to your project)

<key>GUMobileKey</key>
<string>'your-mobile-key'</string>

Location usage keys

  1. Add the following keys to Info.plist file (String value), the corresponding values will be shown to the user by iOS

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>We would like to access your locations</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>We would like to access your locations</string>

If your app supports iOS add

<key>NSLocationAlwaysUsageDescription</key>
<string>We would like to access your locations</string>

  1. Add the following key to Info.plist file (String value), it will be used to show a popup to the user before the provided by iOS. Only if the user accepted this first popup we request the permission to iOS.

<key>GULocationPermissionNotDetermined</key>
<string>We would like to ask your permission to access your locations</string>

Background fetch

In order to obtain a greater number of positions we suggest to enable this feature. To do this carry out these two steps:

  1. Select your project -> Select your target -> Select 'Signing & Capabilities' tab -> tap on '+ Capability' -> select 'Background Modes' -> check 'Background fetch'

  2. In AppDelegate add this code:

//Swift
/* ------ AppDelegate.swift ------ */

func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void){
    //call GeoUniq backgroundFetch() method
    GeoUniq.sharedInstance().backgroundFetch()
}

App Tracking Transparency

iOS 14 introduced the permission request to get the device's IDFA. In this regard, we have introduced two methods in our framework.

The first one checking the permission status:

...
let permissionStatus = GeoUniq.sharedInstance().getATTrackingAuthorizationStatus()
...

And the second one that makes the request and returns the user's choice:

...
GeoUniq.sharedInstance().requestATTrackingAuthorization { (status) in
    // Use status if you want
}
...

It is possible to use these methods but also the methods provided directly by iOS. There is no need to communicate to our framework the outcome of the permission. Invoke the request method as soon as possible. For example right after the enable.

...
GeoUniq.sharedInstance().enable()
GeoUniq.sharedInstance().requestATTrackingAuthorization { (status) in
    // Use status if you want
}
...

Important: Before invoking the method for the request (both Geouniq and iOS) it is necessary to insert the key in the plist

<key>NSUserTrackingUsageDescription</key>
<string>The identifier will be used to personalise ads across apps and websites and to conduct marketing and research analysis</string>

Initialize Users

In order to track geofencing events, you need to initialize a user in your Cloud4Wi account.

The method to initialize users is exposed in the WiFi SDK, so you need to integrate also the WiFi SDK into your project.

Once both the WiFi and Location SDKs are installed you can use the following snippet to initialize the customer in Cloud4Wi as soon the deviceId is assigned to the phone. This function will initialize an anonymous user without any additional attribute or personal data associated.

let _ = GeoUniq.sharedInstance { deviceId in
            let cloud4WiSDKWiFi = Cloud4WiSDKWiFi.init()
            cloud4WiSDKWiFi.setupCustomer { customerResponse in
                if let customerResponse = customerResponse {
                    print(customerResponse)
                }
            } onError: { error in
                print(error!)
            }
        }

In the alternative, you can use the native WiFi SDK methods to initialize a customer.

Last updated