Skip to content
Notifie
Documentation
DocsSDKs

SDKs

Swift SDK

The complete iOS surface: configuration, identity, events, and APNs enrolment.

Install

Podfile
pod 'Notifie', '0.1.0-beta.5'
Package.swift
.package(url: "https://github.com/rohit1521/notifie", exact: "0.1.0-beta.5")

Initialize

Only apiKey is required. Every other parameter has a working default.

App.swift
import Notifie

Notifie.initialize(
    apiKey: processInfo.notifieKey,
    batchSize: 20,
    flushInterval: 30,
    maxQueueSize: 1000,
    logLevel: .silent
)
ParameterDefaultMeaning
apiKeyrequiredSDK ingest key
baseURLhttps://notifie.devAdvanced override for local integration tests
batchSize20Events per upload
flushInterval30Seconds between automatic flushes
maxQueueSize1000Offline cap before the oldest events drop
logLevel.silent.silent .error .warning .info .debug
transportURLSessionTransport()Swap for a fake in tests

Identity

Sign-in and sign-out
Notifie.identify("user-42", properties: ["plan": .string("pro")])

// On logout, so the next user does not inherit this anonymous id.
Notifie.reset()

Before identify, events carry a generated anonymous id. Identifying links the prior anonymous history to the user. Property values are flat scalars — string, number, boolean, or null.

If the app uses Firebase Authentication, pass FirebaseAuth.currentUser.uid as this external user ID after sign-in. Notifie does not automatically read Firebase Auth and never replaces the application's source of identity.

Events

Track product evidence
Notifie.track("checkout_completed", properties: [
    "plan": .string("pro"),
    "amount": .double(29.0)
])

// Deliver anything queued right now, e.g. before backgrounding.
await Notifie.flush()

Events are queued and uploaded in batches, so track never blocks and works offline. flush also waits for any in-flight identify or reset, so properties set immediately before it are included.

Already collected for you

Tracking these names yourself duplicates them: install first_open app_open session_start notification_received notification_opened notification_clicked. Device context such as app version, platform, timezone, locale, and notification_permission is attached as user properties.

Push notifications

One call owns the permission request, APNs registration, token persistence, server registration, receipt attribution, and open attribution. Notifie observes Apple's delegate callbacks and forwards them unchanged to any delegate your app already uses.

Ask at a moment the user understands
switch await Notifie.enableNotifications() {
case .enrolled:
    break                       // permission granted and a token registered
case .denied:
    showWhyNotificationsHelp()  // iOS will not prompt again
case .noToken(let reason):
    log("no APNs token: \(reason)")
case .notInitialised:
    assertionFailure("call Notifie.initialize first")
}

The result is a Notifie.NotificationEnrolment, deliberately not a Bool. "The user said no" and "this is a simulator" need very different responses, and collapsing them hides bugs. .noToken normally means a simulator or a missing Push Notifications capability. Pass options: to change the requested authorisation from the default alert, badge, and sound.

You do not edit AppDelegate or install a UNUserNotificationCenterDelegate for Notifie. If the app already implements those callbacks, they still run normally. A lower-level registerPushToken overload remains available for cross-platform bridges that already own APNs registration.

Reading a payload

Handling an opened notification
if let url = Notifie.deepLink(from: response.notification.request.content.userInfo) {
    router.open(url)
}

The SDK extracts the deep link; it never opens it. Navigation stays your decision.