Structures
The following structures are available globally.
-
Configuration for automatic cleanup of push notifications.
This configuration allows for managing storage by removing old or excessive notifications. Cleanup can be performed automatically when new notifications are processed, or manually by calling the cleanup methods on the PushClient.
Cleanup Strategies
- None: No automatic cleanup is performed
- Count-Based: Removes oldest notifications when count exceeds maximum
- Age-Based: Removes notifications older than specified age
- Hybrid: Applies both count-based and age-based cleanup
Usage Examples
See more// Count-based cleanup (default) let config1 = NotificationCleanupConfig() // Age-based cleanup (remove after 7 days) let config2 = NotificationCleanupConfig( cleanupMode: .ageBased, maxNotificationAgeDays: 7 ) // Hybrid cleanup let config3 = NotificationCleanupConfig( cleanupMode: .hybrid, maxStoredNotifications: 50, maxNotificationAgeDays: 14 ) // No cleanup let config4 = NotificationCleanupConfig(cleanupMode: .none)Declaration
Swift
public struct NotificationCleanupConfig : Sendable -
Represents a Push credential for push authentication.
A Push credential contains all the information needed to register a device for push notifications and to authenticate using push challenges. This model follows the PingAM (ForgeRock) push authentication protocol.
Credential Sources
Push credentials are typically created by:
- Scanning a QR code containing a
pushauth://ormfauth://URI - Receiving credential information from a server API
- Importing from backup or migration
Security Considerations
- The
sharedSecretis used for cryptographic operations and must be protected - Credentials can be locked based on policy violations
- All credential data should be stored securely in the Keychain
Usage Example
See more// From QR code let credential = try await PushCredential.fromUri(qrCodeUri) // Manual creation let credential = PushCredential( issuer: "MyCompany", accountName: "user@example.com", serverEndpoint: "https://am.example.com/push", sharedSecret: "base64EncodedSecret" )Declaration
Swift
public struct PushCredential : Codable, Identifiable, @unchecked Sendable, CustomStringConvertible - Scanning a QR code containing a
-
Represents a device token for push notifications.
A device token is a unique identifier assigned by the Apple Push Notification service (APNs) to a specific device and application combination. This token is required for sending push notifications to the device.
Token Management
Device tokens should be updated whenever:
- The app is installed or reinstalled
- The device is restored from backup
- The user updates iOS to a new major version
- The token changes (APNs may regenerate tokens periodically)
Security Considerations
- Tokens are device and app-specific
- Tokens should be stored securely in the Keychain
- Tokens should be sent to the server over secure connections only
- Expired or invalid tokens should be removed from the server
Usage Example
See more// When receiving a device token from APNs func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { let tokenString = deviceToken.map { String(format: "%02.2hhx", $0) }.joined() let pushDeviceToken = PushDeviceToken(token: tokenString) // Store and register with server }Declaration
Swift
public struct PushDeviceToken : Codable, Identifiable, Sendable, Equatable -
Represents a push notification authentication challenge.
A Push notification contains all the information about an authentication request received via push notification. It includes the notification content, challenge data, expiration information, and response status.
Notification Types
Push notifications can be of different types:
- DEFAULT: Simple approve/deny notification
- CHALLENGE: Notification requiring challenge verification (e.g., number matching)
- BIOMETRIC: Notification requiring biometric authentication
Lifecycle
- Created: Notification is received and stored
- Pending: Waiting for user action
- Approved/Denied: User has responded
- Expired: TTL has elapsed
Usage Example
// Process incoming notification let notification = try await client.processNotification(userInfo) // Check if expired if notification.isExpired { print("Notification has expired") return } // For challenge notifications, get the numbers if notification.pushType == .challenge { let numbers = notification.getNumbersChallenge() // Display numbers to user } // Approve or deny try await client.approveNotification(notification.id)See moreNote
Notifications have a time-to-live (TTL) and can expire.Declaration
Swift
public struct PushNotification : Codable, Identifiable, @unchecked Sendable, CustomStringConvertible
View on GitHub
Structures Reference