Mobile SDK
iOS SDK
Swift package setup, Firebase wiring, push permission, tap handling and deep links on iOS.
Install#
- Add the
NerjaSDKSwift package and Firebase'sFirebaseMessaging(Swift Package Manager). - Add
GoogleService-Info.plist; enable Push Notifications and Background Modes → Remote notifications. - Upload your APNs authentication key in Firebase (see push setup).
Wire it up#
AppDelegate.swift
FirebaseApp.configure()
Messaging.messaging().delegate = self
UNUserNotificationCenter.current().delegate = self
Nerja.shared.configure(baseURL: "https://api.nerja.ai", appKey: "nak_pk_live_YOUR_KEY", ctaTitle: "Shop now")
// after login
Nerja.shared.identify(userId: "user_42", userHash: hashFromYourBackend, traits: ["email": email])
// Firebase → Nerja
func messaging(_ m: Messaging, didReceiveRegistrationToken t: String?) {
if let t { Nerja.shared.registerPushToken(t) }
}
// app open: willPresent → Nerja.shared.handleNotificationDelivered(n)
// tap: didReceive → Nerja.shared.handleNotificationResponse(r)Note
The device token is requested right away; the permission prompt only decides whether notifications are displayed. Ask for permission with
Nerja.shared.requestNotificationPermission() at a good moment.Images in notifications#
iOS needs a Notification Service Extension to attach a picture. Add the extension target with the provided NotificationService.swift; Nerja already sends the image URL and mutable-content.
Deep links#
swift
Nerja.shared.linkHandler = { url in
// url = myshop://product/42 (or the website URL)
router.open(url)
return true // handled; false → website fallback
}What Apple requires#
| Requirement | Why |
|---|---|
| Paid Apple Developer Program | Push Notifications capability and an APNs key are not available to free accounts |
| APNs auth key uploaded to Firebase | Firebase needs it to deliver to iPhones; without it you get “Invalid APNs credential” |
| A physical iPhone for the final test | The simulator cannot receive real pushes from FCM |
Prefer to talk it through? Book a 30-minute call with the Nerja team.
Something unclear or missing? Email support@nerja.ai and we will improve this page.