iOS
Integrate the Msgera iOS SDK and Notification Service Extension via Swift Package Manager.
The Msgera iOS SDK connects directly to Apple Push Notification service (APNs) over HTTP/2 using your .p8 authentication key. It ships two Swift Package Manager products: MsgeraPush for your main app target and MsgeraPushExtension for rich notification images and delivery receipts.
1. Upload your APNs .p8 key
In your Apple Developer account under Certificates, Identifiers & Profiles → Keys, create a key with Apple Push Notifications service (APNs) enabled. In the Msgera dashboard under Platforms → iOS, enter the .p8 contents, Key ID, Team ID, and your app's Bundle ID.
2. Add the Swift Package
In Xcode, choose File → Add Package Dependencies… and enter https://github.com/msgera/push-sdks. Link MsgeraPush to your main app target and MsgeraPushExtension to your Notification Service Extension target.
dependencies: [
.package(url: "https://github.com/msgera/push-sdks.git", from: "1.1.0")
]3. Initialize on launch
Enable the Push Notifications capability in Xcode under Signing & Capabilities. Then call MsgeraPush.shared.start(appId:appGroup:) in your AppDelegate. Use an App Group id your Apple account owns, such as group.<bundle id>.msgera. Also enable Background Modes → Remote notifications on the app:
import MsgeraPush
// Inside your existing application(_:didFinishLaunchingWithOptions:)
MsgeraPush.shared.start(
appId: "YOUR_PUBLIC_ID",
appGroup: "group.YOUR.BUNDLE.msgera"
)By default, MsgeraPush.automaticSetup is true and forwards APNs device token registration and launch notification taps automatically. If your app disables swizzling, set MsgeraPush.automaticSetup = false before start(appId:) and forward didRegisterForRemoteNotificationsWithDeviceToken manually.
4. Request permission & identify users
// Prompt the user for notification permission
MsgeraPush.shared.requestPermission(fallbackToSettings: true) { granted in
print("Notification permission granted:", granted)
}
// Link device to your signed-in user
MsgeraPush.shared.login(externalUserId: "user_123", userHash: hmacFromBackend)
// Unlink on sign-out
MsgeraPush.shared.logout()5. Rich images & delivery receipts (Notification Service Extension)
In Xcode, select File → New → Target… → Notification Service Extension. Add the MsgeraPushExtension library to that target, set the same App Group on the extension, add Info.plist key MsgeraAppGroup with that group id, and replace NotificationService.swift with:
import MsgeraPushExtension
final class NotificationService: MsgeraNotificationService {}Why the Notification Service Extension matters
"mutable-content": 1. MsgeraNotificationService automatically downloads imageUrl attachments (with a 20-second timeout) and reports the received delivery event even when your app is closed.Custom sounds
.caf, .wav, or .aiff). iOS has no notification channels. A send uses the channel sound as aps.sound, and appends .caf when the name has no extension. default is the system sound and none is silent.