Userpilot iOS SDK enables you to capture user insights and deliver personalized in-app experiences in real time. With just a one-time setup, you can immediately begin leveraging Userpilot’s analytics and engagement features to understand user behaviors and guide their journeys in-app. This document provides a step-by-step walkthrough of the installation Userpilot device mode support to your applications via this plugin for Analytics-Swift.

Installation

In the Xcode File menu, click Add Packages. You’ll see a dialog where you can search for Swift packages. In the search field, enter the URL to this repo. https://github.com/userpilot/segment-userpilot-ios You’ll then have the option to pin to a version, or specific branch, as well as which project in your workspace to add it to. Once you’ve made your selections, click the Add Package button. or using Package.swift Open your Package.swift file and add the following do your the dependencies section, and replace the <latest_version> with the latest release version.
Check Userpilot iOS SDK for more details.
.package(
	url: "https://github.com/Userpilot/segment-userpilot-ios.git",
    from: "<latest_version>"
),

Initialization

Just under your Analytics-Swift library setup, call analytics.add(plugin: ...) to add an instance of the plugin to the Analytics timeline.
import Segment
import SegmentUserpilot
 
let analytics = Analytics(configuration: Configuration(writeKey: "<YOUR_WRITE_KEY>")
    .flushAt(3)
    .trackApplicationLifecycleEvents(true))
analytics.add(plugin: UserpilotDestination())
Your events will now begin to flow to Userpilot in device mode.

Userpilot SDK callbacks

To gain full control and utilize the full capabilities of the Userpilot SDK, you can configure it using the UserpilotDestination initializer with a configuration lambda. For example, to handle Userpilot deep links, assign a class as the navigationDelegate and conform to the UserpilotNavigationDelegate protocol to manage navigation events triggered by the SDK:
// SegmentManager.swift
private let userpilotDestination = UserpilotDestination { config in
	config.logging(enabled: true)
}
userpilotDestination.userpilot?.navigationDelegate = self
analytics.add(plugin: userpilotDestination)

// confirm UserpilotNavigationDelegate
extension SegmentManager: UserpilotNavigationDelegate {
    func navigate(to url: URL) {
    
    }
}