iOS SDK
Beta · 0.1.0-beta.1 · iOS 15+ · SwiftUI and UIKit
The Swift SDK owns installation bootstrap, APNs token updates, Keychain credentials, bounded offline event/receipt retry, consent, identity, actions, receipts, and deep-link extraction.
Prerequisites
- Create an iOS app in PushHub and configure its APNs
.p8key, team ID, key ID, and bundle ID. - Enable Push Notifications and required background modes in Xcode.
- In App → Integration → Client SDK access, create a publishable
ph_pub_key. - Never place a server
ph_live_key in an app bundle.
Install
In Xcode, select File → Add Package Dependencies, enter the repository URL, and select the PushHub product from sdk/ios:
https://github.com/kemegames-studio/pushhub.git
The Beta source artifact is also available as pushhub-ios-0.1.0-beta.1.zip.
Configure
let configuration = try PushHubConfiguration(
appId: UUID(uuidString: "YOUR_APP_ID")!,
publishableKey: "ph_pub_YOUR_PUBLISHABLE_KEY"
)
try await PushHub.shared.configure(configuration)
Configuration is idempotent and does not show UI or ask for permission.
Permission and APNs registration
let granted = try await PushHubNotifications.requestAuthorization()
if granted {
await MainActor.run { UIApplication.shared.registerForRemoteNotifications() }
}
func application(_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken token: Data) {
Task { try await PushHub.shared.start(deviceToken: token) }
}
The SDK stores its installation credential with kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly. The provider token is converted to lowercase hexadecimal and never exposed by diagnostics or logs.
Notification callbacks
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification) async -> UNNotificationPresentationOptions {
await PushHubNotifications.handleForeground(notification)
return [.banner, .sound, .badge]
}
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse) async {
if let url = await PushHubNotifications.handleResponse(response) {
// Validate the allowed scheme/host, then route inside the application.
}
}
The helpers report signed received/opened/action receipts. They do not claim delivery when iOS does not execute the application and do not navigate automatically.
Identity, consent, and events
try await PushHub.shared.identify("player-1842", attributes: ["tier": "gold", "region": "mena"])
try await PushHub.shared.setConsent(.granted)
try await PushHub.shared.track("level_completed", properties: ["level": "20"])
try await PushHub.shared.unlinkUser() // on logout
Retryable writes are stored in Keychain as a bounded queue of at most 100 operations for seven days. Call flushPending() on a foreground transition for immediate recovery; start() also flushes it.
Reset and diagnostics
await PushHub.shared.reset()
let state = await PushHub.shared.diagnostics()
Reset attempts server deactivation before clearing local state. Diagnostics excludes publishable and installation credentials, APNs token, identity, content, and event properties.
See compatibility.json on GitHub and the sample.