Skip to main content
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:
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: 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:
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 and tag events with the version that sent them. Every other option is described in Configuration.

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: