PushizoDocs
Başlarken

iOS hızlı başlangıç

APNs anahtarını bağlayın, Pushizo iOS SDK'sını SPM/CocoaPods ile ekleyin, AppDelegate'te başlatın, izin isteyin ve test push gönderin.

Pushizo iOS SDK'sı Swift 5.9, iOS 15+ hedefler; swizzling kullanmaz, APNs token'ı açıkça SDK'ya iletilir. Tüm API için iOS SDK.

APNs kimlik bilgisini bağlayın

Apple Developer → Keys → APNs anahtarı (.p8), Key ID ve Team ID. Dashboard → Kanallar → iOS Push → .p8, Key ID, Team ID, Bundle ID, ortam (sandbox Xcode build, production TestFlight/App Store) → Doğrula. .p12 sertifikası da desteklenir. Gizli anahtar şifreli saklanır ve hiçbir yanıtta geri dönmez.

Xcode yetenekleri

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

Paketi ekleyin

  • SPM: File → Add Package Dependencies → https://github.com/exec0de/pushizo-ios (monorepo içinden sdk/ios). Uygulama hedefine Pushizo, Notification Service Extension hedefine PushizoExtension.
  • CocoaPods: pod 'Pushizo'; NSE hedefinde pod 'Pushizo/Extension'.

Başlatın

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.example.com"   // kendi sunucunuz
            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)
    }
}

SwiftUI'de @UIApplicationDelegateAdaptor(AppDelegate.self) ile bağlayın.

İzin isteyin ve kullanıcıyı tanıtın

Pushizo.Notifications.requestPermission { granted in
    // izin sonucu; abonelik izin verilince otomatik kaydedilir
}
Pushizo.login("user_42")                 // kimliği bildiğiniz anda; cihazlar aynı kullanıcıda birleşir
Pushizo.User.addTags(["plan": "pro"])

Notification Service Extension (önerilir)

Zengin medya (big_picture, ios_attachments), rozet birleştirme ve cihaza ulaştı (received) kaydı için File → New → Target → Notification Service Extension ekleyip PushizoNotificationServiceExtension alt sınıfını kullanın; adımlar iOS SDK → NSE.

Test push

Gerçek cihazda (simülatör APNs almaz) uygulamayı açın; Dashboard → Abonelikler'de ios_push kaydı görünür. Kaydı Test cihazı yapıp Test push gönder. Ortam uyuşmazlığı (sandbox/production) en sık hatadır; cihaz bazında ortam embedded.mobileprovision'dan tespit edilir, options.apnsEnvironment ile ezilebilir.

İlgili: critical alert ve interruption level, Live Activities, iOS push kanalı.

Bu sayfada