iOS SDK API Reference
Generated from DocC documentation in HoberKit. The Hober enum acts as a namespace; all methods are static.
Note: The full interactive DocC archive is hosted at
https://docs.hober.io/ios-sdk/docc/and regenerated on everyhoberkit/v*release tag.
Hober.configure(sdkKey:channelId:)
Configures the SDK with the provided credentials.
Call this once, early in your app lifecycle — typically in application(_:didFinishLaunchingWithOptions:).
Declaration
public static func configure(sdkKey: String, channelId: String) throws
Parameters
| Parameter | Type | Description |
|---|---|---|
sdkKey | String | Your project SDK key from the Hober dashboard. |
channelId | String | The notification channel identifier for this app. |
Throws: HoberError.invalidConfiguration if either argument is empty.
Notes:
- Calling this method a second time overwrites the previous configuration and logs a warning.
- Thread-safe — may be called from any thread.
Hober.requestPermission(center:registrar:)
Requests the user's permission to display push notifications.
Declaration
public static func requestPermission(
center: UNAuthorizationRequesting = UNUserNotificationCenter.current(),
registrar: RemoteNotificationRegistering = MainThreadRegistrar()
) async throws -> UNAuthorizationStatus
Parameters
| Parameter | Type | Description |
|---|---|---|
center | UNAuthorizationRequesting | The authorization center. Defaults to UNUserNotificationCenter.current(). |
registrar | RemoteNotificationRegistering | Used to register with APNs. Defaults to MainThreadRegistrar(). |
Returns: UNAuthorizationStatus — the resolved authorization status after the user responds.
Throws:
HoberError.notConfiguredifconfigure(sdkKey:channelId:)has not been called.
Notes:
- When the user grants permission, registers the app with APNs on the main thread.
- The APNs device token is delivered separately via
application(_:didRegisterForRemoteNotificationsWithDeviceToken:)and must be forwarded toHober.registerDevice(token:). - If already
.authorized, returns immediately without showing a dialog.
Hober.identifySubscriber(externalId✉️attributes:session:)
Associates the current device session with a known subscriber by calling POST /v1/subscribers/upsert.
Declaration
public static func identifySubscriber(
externalId: String,
email: String? = nil,
attributes: [String: String]? = nil,
session: URLSession = .shared
) async throws -> HoberSubscriber
Parameters
| Parameter | Type | Description |
|---|---|---|
externalId | String | Your application's user identifier. Must not be empty. |
email | String? | Optional email address for the subscriber. |
attributes | [String: String]? | Optional key-value string attributes. |
session | URLSession | The URL session for networking. Defaults to URLSession.shared. |
Returns: HoberSubscriber — the subscriber record returned by the Hober backend.
Throws:
HoberError.notConfiguredifconfigurehas not been called.HoberError.invalidArgumentifexternalIdis empty.HoberError.serverError(statusCode:message:)on 4xx/5xx responses.
Hober.registerDevice(token:session:)
Registers the APNs device token with the Hober backend by calling POST /v1/devices.
Call this from application(_:didRegisterForRemoteNotificationsWithDeviceToken:).
Declaration
public static func registerDevice(
token: Data,
session: URLSession = .shared
) async throws -> HoberDevice
Parameters
| Parameter | Type | Description |
|---|---|---|
token | Data | The raw APNs device token data provided by the OS. |
session | URLSession | The URL session for networking. Defaults to URLSession.shared. |
Returns: HoberDevice — the device record returned by the Hober backend.
Throws:
HoberError.notConfiguredifconfigure(sdkKey:channelId:)has not been called.HoberError.subscriberNotIdentifiedifidentifySubscriberhas not been called.HoberError.serverError(statusCode:message:)on non-2xx responses.
HoberAppDelegate
A convenience UIApplicationDelegate subclass that forwards APNs token callbacks to Hober.registerDevice(token:) automatically.
Declaration
open class HoberAppDelegate: UIResponder, UIApplicationDelegate
Usage
@main
class AppDelegate: HoberAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
try? Hober.configure(sdkKey: "YOUR_SDK_KEY", channelId: "default")
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
Types
HoberSubscriber
public struct HoberSubscriber: Decodable {
public let id: String
public let externalId: String
public let email: String?
}
HoberDevice
public struct HoberDevice: Decodable {
public let id: String
public let token: String
public let platform: String
}
HoberError
public enum HoberError: Error {
case invalidConfiguration
case notConfigured
case invalidArgument
case subscriberNotIdentified
case serverError(statusCode: Int, message: String)
}