PushizoDocs
Getting started

iOS quickstart

Connect your APNs key, add the Pushizo iOS SDK with SPM/CocoaPods, initialize it in AppDelegate, request permission and send a test push.

The Pushizo iOS SDK targets Swift 5.9 and iOS 15+; it does not use swizzling, and the APNs token is passed to the SDK explicitly. For the full API see the iOS SDK.

Connect the APNs credential

Apple Developer → Keys → APNs key (.p8), Key ID and Team ID. Dashboard → Channels → iOS Push → .p8, Key ID, Team ID, Bundle ID, environment (sandbox for Xcode builds, production for TestFlight/App Store) → Verify. .p12 certificates are also supported. The secret key is stored encrypted and never returned in any response.

Xcode capabilities

Signing & Capabilities → Push Notifications and Background Modes → Remote notifications.

Add the package

  • SPM: File → Add Package Dependencies → https://github.com/pushizo/pushizo-ios (sdk/ios inside the monorepo). Add Pushizo to the app target and PushizoExtension to the Notification Service Extension target.
  • CocoaPods: pod 'Pushizo'; in the NSE target, pod 'Pushizo/Extension'.

Initialize

import Pushizo

final class AppDelegate: NSObject, UIApplicationDelegate {
    func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
        Pushizo.initialize("app_…", launchOptions: launchOptions) { options in
            // options.apiUrl = "https://api.pushizo.com"   // self-hosted
            options.logLevel = .warn
        }
        return true
    }
    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        Pushizo.setDeviceToken(deviceToken)
    }
    func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
        Pushizo.setDeviceTokenError(error)
    }
}

In SwiftUI, connect it with @UIApplicationDelegateAdaptor(AppDelegate.self).

Request permission and identify the user

Pushizo.Notifications.requestPermission { granted in
    // permission result; the subscription is registered automatically once permission is granted
}
Pushizo.login("user_42")                 // as soon as you know the identity; devices merge under the same user
Pushizo.User.addTags(["plan": "pro"])

Notification Service Extension (recommended)

For rich media (big_picture, ios_attachments), badge merging and device-reached (received) tracking, add File → New → Target → Notification Service Extension and use the PushizoNotificationServiceExtension subclass; steps in iOS SDK → NSE.

Test push

Open the app on a real device (the simulator does not receive APNs); an ios_push record appears under Dashboard → Subscriptions. Mark the record as a Test device and click Send test push. An environment mismatch (sandbox/production) is the most common error; the environment is detected per device from embedded.mobileprovision and can be overridden with options.apnsEnvironment.

Related: critical alerts and interruption level, Live Activities, iOS push channel.

On this page