Introduction
Lerix delivers push notifications on iOS using Apple Push Notification service (APNs) directly — no Firebase required. After you complete the iOS installation, follow the steps below to enable push delivery in your app.Make sure you have initialized the SDK with
Lerix.initialize() before configuring push notifications.Set up APNs authentication
You need an active Apple Developer account to send push notifications on iOS.- In the Apple Developer portal, go to Certificates, Identifiers & Profiles → Keys.
- Create a new key with Apple Push Notifications service (APNs) enabled.
- Download the
.p8authentication key and note the Key ID. You can only download the key once. - Upload the
.p8file to the Lerix dashboard, under Notifications → Settings. - In Certificates, Identifiers & Profiles → Identifiers, make sure your app’s own App ID has the Push Notifications capability enabled. This is separate from the
.p8key above and is required even though Lerix’s token-based auth doesn’t need a per-app certificate — APNs still rejects pushes to an App ID it has no record of.
Enable the capability in Xcode
Add Push Notifications and Background Modes → Remote notifications under your app target’s Signing & Capabilities tab.Wire up the AppDelegate
AppDelegate.swift
Request permission and observe notifications
setOnNotificationTapped somewhere with access to your navigation stack, since a tap almost always means routing to a specific screen based on payload.metadata rather than just logging it.
A tap is delivered reliably even when it’s what launched the app from a fully
terminated state — call
setOnNotificationTapped as soon as your root view
appears, and any tap that happened before your app finished starting up is
replayed automatically once the callback is registered.The notification payload
setOnNotificationReceived and setOnNotificationTapped both receive a LerixNotificationPayload:
Device identifiers
Three different methods return three different things — use the right one for what you’re doing:nil until notification permission is granted and registration completes.
Sending a custom sound
Setsound when sending a notification — from the dashboard’s Send notification tab, or the REST API’s sound parameter — to play a bundled sound file instead of the device default.
- The file must already ship inside your app’s bundle — Lerix only passes the filename through, it never hosts or uploads sound files.
- Pass the filename with its extension, e.g.
sound.mp3(.wav/.cafalso supported).
Sending metadata
Attach arbitrary custom data withmetadata (a JSON object) when sending — from the dashboard’s Send notification tab, or the REST API’s metadata parameter. It’s delivered back to the device inside payload.metadata:
Sending an image
SetimageUrl when sending a notification — from the dashboard’s Send notification tab, or the REST API’s imageUrl parameter — to show a rich image in the notification. APNs has no native “image” field, so this requires a one-time setup step:
- In Xcode: File → New → Target… → Notification Service Extension. Name it (e.g.
NotificationServiceExtension). - Copy the package’s
NotificationServiceExtension/NotificationService.swiftinto your new extension target, replacing the generated one. - Build and run — no other configuration needed. The backend automatically sets APNs’
mutable-contentflag whenever a notification carries animageUrl, which is what triggers your extension to run.
If the extension isn’t set up, an
imageUrl is silently ignored — the
notification still shows normally with no image, it doesn’t fail to send.payload.imageUrl (in setOnNotificationReceived/setOnNotificationTapped) if you want to show it in a custom in-app banner, in addition to the OS rendering it natively.
Target a user on every device
If your product also ships on other platforms (web, mobile or desktop), add them to the same project and link each install to your own user ID after login. Your backend can then send toexternalUserIds and reach that person
on every device in one request.
Topics
Instead of targeting specific device tokens, a device can subscribe to a named topic — send one notification to the topic and every subscriber receives it. A topic doesn’t need to be created ahead of time; it’s created automatically the first time any device subscribes to it. You can also view, create, and delete topics from the Notifications → Topics tab in the dashboard.sendByTopic: true.