API Reference
Notifications
BioNotificationsStore, BioNotification, and notification connection state types.
The SDK provides a real-time notification system for receiving alerts, updates, and actionable messages from the backend.
BioNotificationsStore
Observable store for managing notifications. Access via sdk.notifications.
public final class BioNotificationsStore: ObservableObjectPublished Properties
| Property | Type | Description |
|---|---|---|
notifications | [BioNotification] | All received notifications |
connectionState | NotificationConnectionState | Current connection status |
unreadCount | Int | Count of unacknowledged notifications |
Events
// Combine publisher for notification events
public var events: AnyPublisher<BioNotificationEvent, Never> { get }Connection Management
// Connect to the notification service
public func connect()
// Disconnect from the notification service
public func disconnect()
// Retry connection immediately
public func retryNow()Notification Actions
// Mark a notification as acknowledged
public func acknowledge(notificationId: String)
// Dismiss a notification
public func dismiss(notificationId: String)
// Clear all notifications
public func clearAll()FCM Token Management
For integrating with Firebase Cloud Messaging:
// Register an FCM token for push notifications
public func registerFcmToken(
token: String,
deviceId: String,
appVersion: String? = nil
)
// Unregister an FCM token
public func unregisterFcmToken(deviceId: String)
// Handle an incoming FCM notification by ID
public func handleFcmNotification(notificationId: String)Example:
// In your AppDelegate or notification handler
func application(_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
if let notificationId = userInfo["bio_notification_id"] as? String {
sdk.notifications.handleFcmNotification(notificationId: notificationId)
}
}BioNotification
A notification received from the backend.
public struct BioNotification: Equatable, Codable {
public let id: String
public let notificationType: String
public let priority: String
public let title: String
public let bodyPreview: String?
public let body: String
public let actionType: String?
public let actionUrl: String?
public let payload: [String: AnyCodableValue]
public let createdAt: Date
public let expiresAt: Date?
public let episodeId: String?
}| Property | Type | Description |
|---|---|---|
id | String | Unique notification identifier |
notificationType | String | Type category (e.g., "alert", "info") |
priority | String | Priority level (e.g., "high", "normal") |
title | String | Display title |
bodyPreview | String? | Short preview text |
body | String | Full notification body |
actionType | String? | Action type (e.g., "url", "deep_link") |
actionUrl | String? | Action URL or deep link |
payload | [String: AnyCodableValue] | Arbitrary key-value metadata |
createdAt | Date | When the notification was created |
expiresAt | Date? | Expiration date (nil = no expiry) |
episodeId | String? | Associated episode/session ID |
NotificationConnectionState
Connection state for the notification service.
public enum NotificationConnectionState: Equatable {
case disconnected
case connecting
case connected
case waitingToReconnect(delay: TimeInterval, attempt: Int, maxAttempts: Int)
case failed(reason: String)
}| State | Description |
|---|---|
.disconnected | Not connected |
.connecting | Connection in progress |
.connected | Connected and receiving notifications |
.waitingToReconnect(...) | Waiting before a retry attempt |
.failed(reason:) | Connection permanently failed |
BioNotificationEvent
Events emitted by the notification system.
public enum BioNotificationEvent: Equatable {
case received(BioNotification)
case acknowledged(notificationId: String)
case dismissed(notificationId: String)
case connectionStateChanged(NotificationConnectionState)
}AnyCodableValue
A type-safe wrapper for heterogeneous JSON values, used in notification payloads.
public enum AnyCodableValue: Equatable, Codable {
case string(String)
case int(Int)
case double(Double)
case bool(Bool)
case array([AnyCodableValue])
case dictionary([String: AnyCodableValue])
case null
}Example — reading a notification payload:
if case .string(let level) = notification.payload["severity"] {
print("Severity: \(level)")
}