Installing the Freshpaint iOS SDK

To install the Freshpaint iOS SDK, add the following to your app's Podfile:

pod 'Freshpaint', '0.5.0'

Then run:

pod install --repo-update

To import the Freshpaint SDK use:

import FreshpaintSDK

Then to initialize the SDK, add the following code to your application delegate's didFinishLaunchingWithOptions:

func application(
    _ application: UIApplication, 
    didFinishLaunchingWithOptions 
    launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    ...
    let config = FreshpaintConfiguration(writeKey: "<your environment id>");
    config.trackApplicationLifecycleEvents = true
    config.recordScreenViews = true
    Freshpaint.setup(with: config)
    ...
}

You can get your environment id by going to the Freshpaint sources page.

Freshpaint can automatically track deep links when your app is opened from a custom URL scheme or Universal Link. When enabled, the SDK sends a Deep Link Opened event and includes the opened URL in the event properties.

First, enable deep link tracking when you configure the SDK:

Then forward deep link callbacks from your app to Freshpaint.

For Universal Links, Freshpaint records the url, the activity title when available, and any values from the activity's userInfo. For custom URL scheme links, Freshpaint records the url and any values passed in the options dictionary.

Freshpaint gives you control over when analytics data is collected and when advertising identifiers are included. If your app requires user consent before analytics collection, wait to initialize Freshpaint until after consent is granted, or disable tracking immediately after setup and enable it only after the user opts in.

Calling disable() stops Freshpaint from processing new analytics calls. Calling enable() allows tracking calls to be processed again.

The SDK also supports Apple's App Tracking Transparency (ATT) flow. Freshpaint does not request ATT permission automatically by default. If you want the SDK to request ATT automatically when the app becomes active, set autoRequestATT to true.

Freshpaint only includes the advertising identifier through its ATT-aware APIs when ATT is authorized. If you provide an adSupportBlock, make sure your app has the required user permission before returning an advertising identifier.

You can also request ATT permission yourself and enable Freshpaint only after your consent flow is complete.

Verifying Your Instrumentation

To verify your Freshpaint installation, navigate to the Freshpaint Live View. After opening your app, you should see an Application Opened event show up in Live View:

Note, the Freshpaint SDK batches events, so it can take a minute for the event to show up.

Last updated

Was this helpful?