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

# Install the SDK

> Add the PushNotifAI Swift package to your app and configure it.

Swift 6, iOS 16+ (macOS 13+), and no third-party dependencies.

## Add the package

In Xcode, choose **File > Add Package Dependencies** and enter
`https://github.com/vdsingh/pushnotifai-swift-sdk`. Or in `Package.swift`:

```swift theme={null}
.package(
    url: "https://github.com/vdsingh/pushnotifai-swift-sdk",
    exact: "0.3.0"
),
```

> [!TIP]
>
> Pin an exact version. The SDK you ship should be one you chose, not one a
> resolver picked.

The package has three products. Link each to the right target:

| Product | Link to | What it is |
| - | - | - |
| `PushNotifAI` | your app | the client: events, identity, tokens, taps |
| `PushNotifAINSE` | your Notification Service Extension | the drop-in extension class for [delivery telemetry](https://docs.pushnotif.ai/sdk/delivery-telemetry.md) |
| `PushNotifAICore` | both, automatically | shared types; you rarely import it yourself |

Never link `PushNotifAI` into an extension. It uses `UIApplication`, which
extensions are not allowed to call.

## Configure

Call `Push.configure` once, as early as possible in launch:

```swift theme={null}
import PushNotifAI

@main
struct MyApp: App {
    init() {
        Push.configure(PushConfiguration(
            apiKey: "pna_...",
            baseURL: URL(string: "https://api.pushnotif.ai")!,
            appVersion: Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
        ))
    }
    // ...
}
```

`apiKey` is the app's ingest key from the **SDK Keys** page. Use a different
app, and so a different key, for staging and production builds.

Passing `appVersion` lets the SDK report [`$app_updated`](https://docs.pushnotif.ai/sdk/automatic-events)
and tag events with the version that sent them. Every other option is
described in [Configuration](https://docs.pushnotif.ai/sdk/configuration.md).

## What configuring does for you

With the defaults, `configure` also:

* registers the APNs device token whenever iOS hands one to your app, and
  re-registers on every launch once the user has granted permission
* reports taps and swipe-to-dismiss on our notifications, without changing
  how your own code handles them
* reports app opens, backgrounds, installs, updates and permission changes

It does **not** ask the user for notification permission. When and how to ask
is a product decision, so that stays in your code.

## If you use a dependency container

`Push` is a static convenience wrapper. If your app already injects services,
hold a `PushClient` yourself instead:

```swift theme={null}
let client = PushClient(config: config)
await client.startFlushLoop()
await client.track("lesson_completed", properties: ["lesson_id": id])
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.