ConnectPush

The push notification interface for the Connect iOS SDK. Access via try ConnectSDK.shared.push.

Platform: iOS 15.1+
Language: Swift only (push notifications are not supported in Objective-C apps)
Isolation: @MainActor
Declared in: ConnectSDK

📘

Note

ConnectSDK.shared.push throws ConnectError.pushNotEnabled if push was not configured at enable() time. Always pass a ConnectPushConfig (.automatic, .manual, or one with an App Group identifier) when calling enable().


Getting the push interface

let push = try ConnectSDK.shared.push

Push configuration

Configure push at SDK initialization by passing a ConnectPushConfig to enable(with:). Two modes are available:

ModeWho registers for APNs?Who forwards the device token?Use when
.automaticSDKSDKYou want the Connect SDK to manage APNs registration end-to-end.
.manualYour appYour app (via didRegisterWithToken)You already manage APNs registration or need custom token handling.
public struct ConnectPushConfig: Sendable {
    public let mode: Mode
    public let appGroupIdentifier: String?

    // Convenience constants
    public static let off: ConnectPushConfig
    public static let automatic: ConnectPushConfig
    public static let manual: ConnectPushConfig
}

The SDK manages APNs registration end-to-end. For basic push support:

ConnectSDK.shared.enable(
    with: ConnectConfig(
        appKey: "YOUR_APP_KEY",
        postURL: "https://collector.example.com/collectorPost",
        push: .automatic
    )
)

To enable push delivery tracking and rich media from a Notification Service Extension, provide an App Group identifier:

ConnectSDK.shared.enable(
    with: ConnectConfig(
        appKey: "YOUR_APP_KEY",
        postURL: "https://collector.example.com/collectorPost",
        push: ConnectPushConfig(mode: .automatic, appGroupIdentifier: "group.com.example.YourApp")
    )
)

Status

PropertyTypeDescription
configConnectPushConfigThe push configuration used at enable(with:) time.

Permission request

Use requestAuthorization(options:) to prompt the user for push notification permission directly through the SDK, without calling UNUserNotificationCenter yourself.

ConnectPushAuthorizationOptions

requestAuthorization(options:) accepts a ConnectPushAuthorizationOptions value, which mirrors UNAuthorizationOptions. The commonly used options are:

OptionDescription
.alertDisplay notifications in the notification center and as banners.
.badgeUpdate the app icon badge.
.soundPlay a sound when a notification is delivered.
.provisionalSend notifications without prompting the user first. Notifications are delivered quietly to the notification center — the user can then choose to keep or turn them off.

The default is [.alert, .badge, .sound].

Request permission

let push = try ConnectSDK.shared.push
let (granted, error) = await push.requestAuthorization()

if granted {
    // User granted permission
} else if let error {
    // Permission denied or error
}

To request a non-default set of options:

let (granted, error) = await push.requestAuthorization(options: [.alert, .sound])
📘

Note

requestAuthorization(options:) is available from Connect iOS SDK 2.1.15 (July 2026).

Check current permission state

Use getCurrentAuthorization() to query the current authorization state without prompting the user.

let status = await push.getCurrentAuthorization()
// true  = granted, provisional, or ephemeral
// false = denied
// nil   = not yet determined
📘

Note

getCurrentAuthorization() is available from Connect iOS SDK 2.1.15 (July 2026).

Forward the result manually

If your app manages its own UNUserNotificationCenter authorization flow, forward the result to the SDK using didReceiveAuthorization(granted:error:) instead of calling requestAuthorization(options:).

MethodIsolationDescription
didReceiveAuthorization(granted:error:)nonisolatedNotifies the SDK of the push permission result. Safe to call from any thread.
didReceiveAuthorization(granted:error:) async@MainActorAsync variant with ordering guarantee.
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in
    Task { @MainActor in
        try? ConnectSDK.shared.push.didReceiveAuthorization(granted: granted, error: error)
    }
}
📘

Note

ConnectSDK.shared.push is @MainActor-isolated. In Swift 6, accessing it from the non-isolated requestAuthorization completion handler requires a Task { @MainActor in } wrapper to satisfy strict concurrency checking.


Token registration

MethodIsolationDescription
didFailToRegisterWithError(_:)nonisolatedNotifies the SDK that APNs registration failed. Safe to call from any thread.
didFailToRegisterWithError(_:) async@MainActorAsync variant with ordering guarantee.

Category registration

MethodDescription
registerNotificationCategories()Re-registers Acoustic notification categories with UNUserNotificationCenter. Call this if your app replaces the notification categories after SDK initialization.