Files
breez-sdk-liquid/lib/bindings/langs/swift/Sources/BreezSDKLiquid/TaskProtocol.swift
Ross Savage b493f3dc03 Swift notification plugin (#436)
* Add Swift notification plugin

* Hash the metadata

* Validate min sendable amount

* Remove initializer as base class, UNNotificationServiceExtension, has no default initializer

* Set the PaymentMethod

* Handle PaymentDetails in SwapUpdated

* Improve payment text
2024-08-30 09:20:13 +02:00

34 lines
1.0 KiB
Swift

import UserNotifications
public protocol TaskProtocol : EventListener {
var payload: String { get set }
var contentHandler: ((UNNotificationContent) -> Void)? { get set }
var bestAttemptContent: UNMutableNotificationContent? { get set }
func start(liquidSDK: BindingLiquidSdk) throws
func onShutdown()
}
extension TaskProtocol {
func displayPushNotification(title: String, body: String? = nil, logger: ServiceLogger, threadIdentifier: String? = nil) {
logger.log(tag: "TaskProtocol", line:"displayPushNotification \(title)", level: "INFO")
guard
let contentHandler = contentHandler,
let bestAttemptContent = bestAttemptContent
else {
return
}
if let body = body {
bestAttemptContent.body = body
}
if let threadIdentifier = threadIdentifier {
bestAttemptContent.threadIdentifier = threadIdentifier
}
bestAttemptContent.title = title
contentHandler(bestAttemptContent)
}
}