Add the package
In Xcode, choose File > Add Package Dependencies and enterhttps://github.com/vdsingh/pushnotifai-swift-sdk. Or in Package.swift:
Never link
PushNotifAI into an extension. It uses UIApplication, which
extensions are not allowed to call.
Configure
CallPush.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
If you use a dependency container
Push is a static convenience wrapper. If your app already injects services,
hold a PushClient yourself instead: