> ## Documentation Index
> Fetch the complete documentation index at: https://docs.userpilot.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Analytics iOS Userpilot

> Userpilot iOS SDK enables you to capture user insights and deliver personalized in-app experiences in real time.

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](https://github.com/segmentio/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](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](https://github.com/Userpilot/segment-userpilot-ios/releases).\
Check [Userpilot iOS SDK](../installation/mobile/ios/installation) for more details.

```bash theme={null}
.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.

```swift theme={null}
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:

```swift theme={null}
// 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) {
    
    }
}
```

## **Configurations (Optional)**

| **Parameter**                             | **Type**                    | **Description**                                                                    |
| ----------------------------------------- | --------------------------- | ---------------------------------------------------------------------------------- |
| logging                                   | Bool                        | Enable or Disable logs for SDK<br /><br />**Default: false**                       |
| disableRequestPushNotificationsPermission | Bool                        | Disable request push notifications permission by SDK<br /><br />**Default: false** |
| navigationHandler                         | UserpilotNavigationDelegate | Handle deep link navigation from experiences and push notifications                |
| analyticsDelegate                         | UserpilotAnalyticsDelegate  | Broadcasts analytics events to external listeners for tracking and reporting.      |
| experienceDelegate                        | UserpilotExperienceDelegate | Notify about the display of Experience content.                                    |

<Frame>
  [**For any questions or concerns please reach out to support@userpilot.com**](mailto:support@userpilot.com)
</Frame>
