NotificationService
public final actor NotificationService
This service provides an AsyncStream callback mechanism for processing notifications.
-
notificationEventStreamAsynchronousAwaits the result from
processNotification(forUserInfo:)andretry(userInfo:).Application should call
notificationEventStreamto handle each event.Declaration
Swift
public var notificationEventStream: AsyncStream<NotificationService.State> { get async }Return Value
The state of processing the notification as a
State
-
Undocumented
Declaration
Swift
public init() -
processNotification(forUserInfo:Asynchronous) Processes the received push message.
Throws:
deviceEnvironmentUnsafe(_:)if device environment is unsafe.clientError(_:)if error encountered on processing notification.
Declaration
Swift
public func processNotification(forUserInfo userInfo: [AnyHashable : Any]) async throws -
retry(userInfo:Asynchronous) A mechanism to send the server request again in the event of an error such as a timeout, with no or weak network coverage.
Throws:
deviceEnvironmentUnsafe(_:)if device environment is unsafe.clientError(_:)if server request fails on retying.
Declaration
Swift
public func retry(userInfo: [AnyHashable : Any]) async throws -
updatePushToken(_:Asynchronous) Request to update the push notification token. This function is called whenever the application receives a new push token. The SDK is able to recognize when the same push token is provided. The SDK will return success without making a network call.
Throws:
deviceEnvironmentUnsafe(_:)if device environment is unsafe.clientError(_:)if error on updating the push notification token.
Declaration
Swift
public func updatePushToken(_ token: String) async throws -
Notification Service Errors
See moreDeclaration
-
These are the known message types when a notification is processed.
See moreDeclaration
Swift
public enum KnownMessage : String -
Different types of push messages.
See moreDeclaration
Swift
public enum MessageSeverity : Sendable -
It contains the data received from server
See moreDeclaration
Swift
public struct ServerMessage : Sendable -
State for Notification Service with
See moreprocessNotification(forUserInfo:)andretry(userInfo:).Declaration
Swift
public enum State : Sendable
NotificationService Actor Reference