iOS
Prerequisites: iOS 15+, an app in Settings → Apps with an iOS client key, and an APNs key. Read Concepts.
-
Add the package
https://github.com/mailpidge/mailpidge-swift(productMailPidgeLifecycleSDK). -
In Signing & Capabilities, add Push Notifications, App Attest, and Background Modes → Remote notifications.
-
Configure at launch.
import MailPidgeLifecycleSDKdo {try MailPidgeLifecycle.configure(clientCredential: "mpck_…", appId: "pidgefit-ios")} catch {assertionFailure("MailPidge configuration is invalid: \(error)")}Debug builds: add
pushEnvironment: .sandbox. -
Request permission and register the token.
if try await UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) {UIApplication.shared.registerForRemoteNotifications()}func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {Task { try await MailPidgeLifecycle.registerPushToken(deviceToken) }} -
Identify after sign-in; reset on sign-out.
try await MailPidgeLifecycle.identify(externalUserId: user.id, identityToken: identityToken)await MailPidgeLifecycle.reset() -
Track events and record consent.
try await MailPidgeLifecycle.track("workout_completed", properties: ["minutes": 42])
Images and receipts
Section titled “Images and receipts”Add a Notification Service Extension with the MailPidgeNotificationServiceExtension product and an App Group shared with the app. It attaches images and reports push.confirmed.
On a real device: Settings → Apps → your app → Send test push. The device shows as Active.