Skip to content

Commit

Permalink
Update Breez SDK Swift bindings to version 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
runner authored and runner committed May 3, 2024
1 parent 7431e35 commit 687a6a0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion BreezSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "BreezSDK"
spec.version = "0.4.0-rc5"
spec.version = "0.4.0"
spec.license = { :type => "MIT" }
spec.summary = "Swift bindings to the Breez SDK"
spec.homepage = "https://breez.technology"
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let package = Package(
.library(name: "BreezSDK", targets: ["breez_sdkFFI", "BreezSDK"]),
],
targets: [
.binaryTarget(name: "breez_sdkFFI", url: "https://github.com/breez/breez-sdk-swift/releases/download/0.4.0-rc5/breez_sdkFFI.xcframework.zip", checksum: "9a1c0313e817da24f79130697112ce22e09328ce6da155de85a0f617e8573855"),
.binaryTarget(name: "breez_sdkFFI", url: "https://github.com/breez/breez-sdk-swift/releases/download/0.4.0/breez_sdkFFI.xcframework.zip", checksum: "35980e6ae7ef4552a5bf5680432e91cd437d71d15c3ff3edbf4994f814353b57"),
.target(name: "BreezSDK", dependencies: ["breez_sdkFFI"]),
]
)
4 changes: 3 additions & 1 deletion Sources/BreezSDK/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct Constants {
static let PAYMENT_RECEIVED_NOTIFICATION_TITLE = "payment_received_notification_title"
static let PAYMENT_RECEIVED_NOTIFICATION_FAILURE_TITLE = "payment_received_notification_failure_title"
static let SWAP_TX_CONFIRMED_NOTIFICATION_TITLE = "swap_tx_confirmed_notification_title"
static let SWAP_TX_CONFIRMED_NOTIFICATION_FAILURE_TEXT = "swap_tx_confirmed_notification_failure_text"
static let SWAP_TX_CONFIRMED_NOTIFICATION_FAILURE_TITLE = "swap_tx_confirmed_notification_failure_title"

// Resource Identifier Defaults
Expand All @@ -35,5 +36,6 @@ struct Constants {
static let DEFAULT_PAYMENT_RECEIVED_NOTIFICATION_TITLE = "Received %d sats"
static let DEFAULT_PAYMENT_RECEIVED_NOTIFICATION_FAILURE_TITLE = "Receive Payment Failed"
static let DEFAULT_SWAP_TX_CONFIRMED_NOTIFICATION_TITLE = "Swap Confirmed"
static let DEFAULT_SWAP_TX_CONFIRMED_NOTIFICATION_FAILURE_TITLE = "Redeem Swap Failed"
static let DEFAULT_SWAP_TX_CONFIRMED_NOTIFICATION_FAILURE_TEXT = "Tap to complete swap"
static let DEFAULT_SWAP_TX_CONFIRMED_NOTIFICATION_FAILURE_TITLE = "Swap Ongoing"
}
9 changes: 5 additions & 4 deletions Sources/BreezSDK/Task/RedeemSwap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class RedeemSwapTask : TaskProtocol {
if address == swapInfo.bitcoinAddress {
if (swapInfo.paidMsat > 0) {
self.logger.log(tag: TAG, line: "Swap address \(swapInfo.bitcoinAddress) redeemed succesfully", level: "INFO")
let successRedeemSwap = ResourceHelper.shared.getString(key: Constants.SWAP_TX_CONFIRMED_NOTIFICATION_TITLE, fallback: Constants.DEFAULT_SWAP_TX_CONFIRMED_NOTIFICATION_TITLE)
self.displayPushNotification(title: successRedeemSwap, logger: self.logger, threadIdentifier: Constants.NOTIFICATION_THREAD_SWAP_TX_CONFIRMED)
let notificationTitle = ResourceHelper.shared.getString(key: Constants.SWAP_TX_CONFIRMED_NOTIFICATION_TITLE, fallback: Constants.DEFAULT_SWAP_TX_CONFIRMED_NOTIFICATION_TITLE)
self.displayPushNotification(title: notificationTitle, logger: self.logger, threadIdentifier: Constants.NOTIFICATION_THREAD_SWAP_TX_CONFIRMED)
}
}
break
Expand Down Expand Up @@ -65,7 +65,8 @@ class RedeemSwapTask : TaskProtocol {
}

func onShutdown() {
let failRedeemSwap = ResourceHelper.shared.getString(key: Constants.SWAP_TX_CONFIRMED_NOTIFICATION_FAILURE_TITLE, fallback: Constants.DEFAULT_SWAP_TX_CONFIRMED_NOTIFICATION_FAILURE_TITLE)
self.displayPushNotification(title: failRedeemSwap, logger: self.logger, threadIdentifier: Constants.NOTIFICATION_THREAD_SWAP_TX_CONFIRMED)
let notificationTitle = ResourceHelper.shared.getString(key: Constants.SWAP_TX_CONFIRMED_NOTIFICATION_FAILURE_TITLE, fallback: Constants.DEFAULT_SWAP_TX_CONFIRMED_NOTIFICATION_FAILURE_TITLE)
let notificationBody = ResourceHelper.shared.getString(key: Constants.SWAP_TX_CONFIRMED_NOTIFICATION_FAILURE_TEXT, fallback: Constants.DEFAULT_SWAP_TX_CONFIRMED_NOTIFICATION_FAILURE_TEXT)
self.displayPushNotification(title: notificationTitle, body: notificationBody, logger: self.logger, threadIdentifier: Constants.NOTIFICATION_THREAD_SWAP_TX_CONFIRMED)
}
}
10 changes: 7 additions & 3 deletions Sources/BreezSDK/TaskProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public protocol TaskProtocol : EventListener {
}

extension TaskProtocol {
func displayPushNotification(title: String, logger: ServiceLogger, threadIdentifier: String? = nil) {
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,
Expand All @@ -19,8 +19,12 @@ extension TaskProtocol {
return
}

if threadIdentifier != nil {
bestAttemptContent.threadIdentifier = threadIdentifier!
if let body = body {
bestAttemptContent.body = body
}

if let threadIdentifier = threadIdentifier {
bestAttemptContent.threadIdentifier = threadIdentifier
}

bestAttemptContent.title = title
Expand Down
2 changes: 1 addition & 1 deletion breez_sdkFFI.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "breez_sdkFFI"
spec.version = "0.4.0-rc5"
spec.version = "0.4.0"
spec.license = { :type => "MIT" }
spec.summary = "Low-level bindings to the Breez SDK Rust API"
spec.homepage = "https://breez.technology"
Expand Down

0 comments on commit 687a6a0

Please sign in to comment.