Skip to main content

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 every hoberkit/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

ParameterTypeDescription
sdkKeyStringYour project SDK key from the Hober dashboard.
channelIdStringThe 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

ParameterTypeDescription
centerUNAuthorizationRequestingThe authorization center. Defaults to UNUserNotificationCenter.current().
registrarRemoteNotificationRegisteringUsed to register with APNs. Defaults to MainThreadRegistrar().

Returns: UNAuthorizationStatus — the resolved authorization status after the user responds.

Throws:

  • HoberError.notConfigured if configure(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 to Hober.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

ParameterTypeDescription
externalIdStringYour application's user identifier. Must not be empty.
emailString?Optional email address for the subscriber.
attributes[String: String]?Optional key-value string attributes.
sessionURLSessionThe URL session for networking. Defaults to URLSession.shared.

Returns: HoberSubscriber — the subscriber record returned by the Hober backend.

Throws:

  • HoberError.notConfigured if configure has not been called.
  • HoberError.invalidArgument if externalId is 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

ParameterTypeDescription
tokenDataThe raw APNs device token data provided by the OS.
sessionURLSessionThe URL session for networking. Defaults to URLSession.shared.

Returns: HoberDevice — the device record returned by the Hober backend.

Throws:

  • HoberError.notConfigured if configure(sdkKey:channelId:) has not been called.
  • HoberError.subscriberNotIdentified if identifySubscriber has 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)
}

See Also