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
This commit is contained in:
Ross Savage
2024-08-30 09:20:13 +02:00
committed by GitHub
parent 0053007000
commit b493f3dc03
12 changed files with 600 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
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)
}
}