mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2025-12-22 08:24:21 +01:00
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:
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user