diff --git a/snippets/csharp/Webhook.cs b/snippets/csharp/Webhook.cs index 32b95178..9cfd7645 100644 --- a/snippets/csharp/Webhook.cs +++ b/snippets/csharp/Webhook.cs @@ -7,7 +7,8 @@ public void RegisterWebhook(BlockingBreezServices sdk) // ANCHOR: register-webook try { - sdk.RegisterWebhook("https://your-nds-service.com/notify?platform=ios&token="); + var url = "https://your-nds-service.com/notify?platform=&token="; + sdk.RegisterWebhook(url); } catch (Exception) { @@ -21,7 +22,8 @@ public void UnregisterWebhook(BlockingBreezServices sdk) // ANCHOR: unregister-webook try { - sdk.UnregisterWebhook("https://your-nds-service.com/notify?platform=ios&token="); + var url = "https://your-nds-service.com/notify?platform=&token="; + sdk.UnregisterWebhook(url); } catch (Exception) { diff --git a/snippets/dart_snippets/lib/webhook.dart b/snippets/dart_snippets/lib/webhook.dart index 07876b50..90763eb4 100644 --- a/snippets/dart_snippets/lib/webhook.dart +++ b/snippets/dart_snippets/lib/webhook.dart @@ -2,12 +2,14 @@ import 'package:dart_snippets/sdk_instance.dart'; Future registerWebhook() async { // ANCHOR: register-webook - await breezSDK.registerWebhook(webhookUrl: "https://your-nds-service.com/notify?platform=ios&token="); + String url = "https://your-nds-service.com/notify?platform=&token="; + await breezSDK.registerWebhook(webhookUrl: url); // ANCHOR_END: register-webook } Future unregisterWebhook() async { // ANCHOR: unregister-webook - await breezSDK.unregisterWebhook(webhookUrl: "https://your-nds-service.com/notify?platform=ios&token="); + String url = "https://your-nds-service.com/notify?platform=&token="; + await breezSDK.unregisterWebhook(webhookUrl: url); // ANCHOR_END: unregister-webook } diff --git a/snippets/go/webhook.go b/snippets/go/webhook.go index e568215c..23d2c4cd 100644 --- a/snippets/go/webhook.go +++ b/snippets/go/webhook.go @@ -6,7 +6,8 @@ import ( func RegisterWebhook() { // ANCHOR: register-webook - if err := sdk.RegisterWebhook("https://your-nds-service.com/notify?platform=ios&token="); err != nil { + url := "https://your-nds-service.com/notify?platform=&token=" + if err := sdk.RegisterWebhook(url); err != nil { log.Printf("Webhook register failed: %v", err) } // ANCHOR_END: register-webook @@ -14,7 +15,8 @@ func RegisterWebhook() { func UnregisterWebhook() { // ANCHOR: unregister-webook - if err := sdk.UnregisterWebhook("https://your-nds-service.com/notify?platform=ios&token="); err != nil { + url := "https://your-nds-service.com/notify?platform=&token=" + if err := sdk.UnregisterWebhook(url); err != nil { log.Printf("Webhook unregister failed: %v", err) } // ANCHOR_END: unregister-webook diff --git a/snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/Webhook.kt b/snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/Webhook.kt index afa4270c..fe3d8814 100644 --- a/snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/Webhook.kt +++ b/snippets/kotlin_mpp_lib/shared/src/commonMain/kotlin/com/example/kotlinmpplib/Webhook.kt @@ -5,7 +5,8 @@ class Webhooks { fun registerWebhook(sdk: BlockingBreezServices) { // ANCHOR: register-webook try { - sdk.registerWebhook("https://your-nds-service.com/notify?platform=ios&token=") + val url = "https://your-nds-service.com/notify?platform=&token=" + sdk.registerWebhook(url) } catch (e: Exception) { // Handle error } @@ -15,7 +16,8 @@ class Webhooks { fun unregisterWebhook(sdk: BlockingBreezServices) { // ANCHOR: unregister-webook try { - sdk.unregisterWebhook("https://your-nds-service.com/notify?platform=ios&token=") + val url = "https://your-nds-service.com/notify?platform=&token=" + sdk.unregisterWebhook(url) } catch (e: Exception) { // Handle error } diff --git a/snippets/python/src/webhook.py b/snippets/python/src/webhook.py index 7b24fd67..5f4933f2 100644 --- a/snippets/python/src/webhook.py +++ b/snippets/python/src/webhook.py @@ -3,7 +3,8 @@ def register_webhook(sdk_services): try: # ANCHOR: register-webook - sdk_services.register_webhook("https://your-nds-service.com/notify?platform=ios&token=") + url = "https://your-nds-service.com/notify?platform=&token=" + sdk_services.register_webhook(url) # ANCHOR_END: register-webook except Exception as error: print(error) @@ -12,7 +13,8 @@ def register_webhook(sdk_services): def unregister_webhook(sdk_services): try: # ANCHOR: unregister-webook - sdk_services.unregister_webhook("https://your-nds-service.com/notify?platform=ios&token=") + url = "https://your-nds-service.com/notify?platform=&token=" + sdk_services.unregister_webhook(url) # ANCHOR_END: unregister-webook except Exception as error: print(error) diff --git a/snippets/react-native/webhook.ts b/snippets/react-native/webhook.ts index ca7f83b7..146bd768 100644 --- a/snippets/react-native/webhook.ts +++ b/snippets/react-native/webhook.ts @@ -3,7 +3,8 @@ import { registerWebhook, unregisterWebhook } from '@breeztech/react-native-bree const _registerWebhook = async () => { // ANCHOR: register-webook try { - await registerWebhook('https://your-nds-service.com/notify?platform=ios&token=') + const url = 'https://your-nds-service.com/notify?platform=&token=' + await registerWebhook(url) } catch (err) { console.error(err) } @@ -13,7 +14,8 @@ const _registerWebhook = async () => { const _unregisterWebhook = async () => { // ANCHOR: unregister-webook try { - await unregisterWebhook('https://your-nds-service.com/notify?platform=ios&token=') + const url = 'https://your-nds-service.com/notify?platform=&token=' + await unregisterWebhook(url) } catch (err) { console.error(err) } diff --git a/snippets/rust/src/webhook.rs b/snippets/rust/src/webhook.rs index 511b597f..72bab9cd 100644 --- a/snippets/rust/src/webhook.rs +++ b/snippets/rust/src/webhook.rs @@ -4,10 +4,8 @@ use std::sync::Arc; async fn register_webhook(sdk: Arc) -> Result<()> { // ANCHOR: register-webook - sdk.register_webhook( - "https://your-nds-service.com/notify?platform=ios&token=".to_string(), - ) - .await?; + let url = "https://your-nds-service.com/notify?platform=&token=".to_string(); + sdk.register_webhook(url).await?; // ANCHOR_END: register-webook Ok(()) @@ -15,10 +13,8 @@ async fn register_webhook(sdk: Arc) -> Result<()> { async fn unregister_webhook(sdk: Arc) -> Result<()> { // ANCHOR: unregister-webook - sdk.unregister_webhook( - "https://your-nds-service.com/notify?platform=ios&token=".to_string(), - ) - .await?; + let url = "https://your-nds-service.com/notify?platform=&token=".to_string(); + sdk.unregister_webhook(url).await?; // ANCHOR_END: unregister-webook Ok(()) diff --git a/snippets/swift/BreezSDKExamples/Sources/Webhook.swift b/snippets/swift/BreezSDKExamples/Sources/Webhook.swift index 00e5e69e..3fc60e08 100644 --- a/snippets/swift/BreezSDKExamples/Sources/Webhook.swift +++ b/snippets/swift/BreezSDKExamples/Sources/Webhook.swift @@ -9,12 +9,14 @@ import BreezSDK func registerWebhook(sdk: BlockingBreezServices) throws { // ANCHOR: register-webook - try sdk.registerWebhook(webhookUrl: "https://your-nds-service.com/notify?platform=ios&token=") + let url = "https://your-nds-service.com/notify?platform=&token=" + try sdk.registerWebhook(webhookUrl: url) // ANCHOR_END: register-webook } func unregisterWebhook(sdk: BlockingBreezServices) throws { // ANCHOR: unregister-webook - try sdk.unregisterWebhook(webhookUrl: "https://your-nds-service.com/notify?platform=ios&token=") + let url = "https://your-nds-service.com/notify?platform=&token=" + try sdk.unregisterWebhook(webhookUrl: url) // ANCHOR_END: unregister-webook } diff --git a/src/guide/payment_notification.md b/src/guide/payment_notification.md index d7bb92b6..071ed50a 100644 --- a/src/guide/payment_notification.md +++ b/src/guide/payment_notification.md @@ -18,7 +18,7 @@ By default the Notification Plugin should receive the push notification data in { "notification_type": "payment_received", "notification_payload": "{ \"payment_hash\": \"\" }", - "app_data": "" + "app_data": "..." } ``` The structure and fields of this data can be changed by [customising the push messages](/notifications/custom_messages.md) handling in the Notification Plugin to reflect how your NDS sends this data over push notifications. @@ -36,7 +36,7 @@ The `payment_received` notification type will be received by the webhook in the { "template": "payment_received", "data": { - "payment_hash": "" // The payment hash that is in progress + "payment_hash": "..." // The payment hash that is in progress } } ``` @@ -50,7 +50,7 @@ The `address_txs_confirmed` notification type will be received by the webhook in { "template": "address_txs_confirmed", "data": { - "address": "" // The address of the swap with confirmed funds + "address": "..." // The address of the swap with confirmed funds } } ``` @@ -66,8 +66,8 @@ The `lnurlpay_info` notification type will be received by the webhook in the fol { "template": "lnurlpay_info", "data": { - "callback_url": "", // The URL of the LNURL service - "reply_url": "" // The URL to reply to this request + "callback_url": "...", // The URL of the LNURL service + "reply_url": "..." // The URL to reply to this request } } ``` @@ -79,7 +79,7 @@ The `lnurlpay_invoice` notification type will be received by the webhook in the "template": "lnurlpay_invoice", "data": { "amount": 0, // The amount in millisatoshis within the min/max sendable range - "reply_url": "" // The URL to reply to this request + "reply_url": "..." // The URL to reply to this request } } ``` diff --git a/src/notifications/custom_messages.md b/src/notifications/custom_messages.md index a54c3f53..0e95d385 100644 --- a/src/notifications/custom_messages.md +++ b/src/notifications/custom_messages.md @@ -5,7 +5,7 @@ The Notification Plugin by default handles a specific format of push notificatio { "notification_type": "payment_received", "notification_payload": "{ \"payment_hash\": \"\" }", - "app_data": "" + "app_data": "..." } ``` diff --git a/src/notifications/getting_started.md b/src/notifications/getting_started.md index 84c60bda..2ac00538 100644 --- a/src/notifications/getting_started.md +++ b/src/notifications/getting_started.md @@ -18,7 +18,7 @@ By default the Notification Plugin should receive the push notification data in { "notification_type": "payment_received", "notification_payload": "{ \"payment_hash\": \"\" }", - "app_data": "" + "app_data": "..." } ``` The structure and fields of this data can be changed by [customising the push messages](custom_messages.md) handling in the Notification Plugin to reflect how your NDS sends this data over push notifications. @@ -36,7 +36,7 @@ The `payment_received` notification type will be received by the webhook in the { "template": "payment_received", "data": { - "payment_hash": "" // The payment hash that is in progress + "payment_hash": "..." // The payment hash that is in progress } } ``` @@ -50,7 +50,7 @@ The `address_txs_confirmed` notification type will be received by the webhook in { "template": "address_txs_confirmed", "data": { - "address": "" // The address of the swap with confirmed funds + "address": "..." // The address of the swap with confirmed funds } } ``` @@ -66,8 +66,8 @@ The `lnurlpay_info` notification type will be received by the webhook in the fol { "template": "lnurlpay_info", "data": { - "callback_url": "", // The URL of the LNURL service - "reply_url": "" // The URL to reply to this request + "callback_url": "...", // The URL of the LNURL service + "reply_url": "..." // The URL to reply to this request } } ``` @@ -79,7 +79,7 @@ The `lnurlpay_invoice` notification type will be received by the webhook in the "template": "lnurlpay_invoice", "data": { "amount": 0, // The amount in millisatoshis within the min/max sendable range - "reply_url": "" // The URL to reply to this request + "reply_url": "..." // The URL to reply to this request } } ``` diff --git a/src/notifications/setup_nds.md b/src/notifications/setup_nds.md index f591ee66..6a4ffc63 100644 --- a/src/notifications/setup_nds.md +++ b/src/notifications/setup_nds.md @@ -2,23 +2,23 @@ Receiving push notifications involves using an Notification Delivery Service (NDS) as an intermediary to receive the webhook event from one of the SDK services. These can be currently one of several services that provide information about events that the Breez SDK registers for. For example, payment events from the LSP or swap transaction confirmation events from the chain service. The NDS then processes this information and dispatches a push notification to the intended mobile device, ensuring the user receives timely updates about incoming events. This architecture necessitates developers set up and maintain their own NDS, tailored to handle and forward these notifications efficiently. An example payload when a `payment_received` POST request to the webhook URL contains the following JSON formatted structure: -``` +```json { "template": "payment_received", "data": { - "payment_hash": [payment hash] + "payment_hash": "..." // The payment hash that is in progress } } ``` The need to run your own NDS is because it's configured to send push notifications to your application users and therefore should be configured with the required keys and certificates. You can use our [reference NDS implementation](https://github.com/breez/notify) as a starting point or as is. Our implementation of the NDS expects URLs in the following format: ``` -https://your-nds-service.com/notify?platform=&token=[PUSH_TOKEN] +https://your-nds-service.com/notify?platform=&token= ``` -This is the same format used when [registering a webhook](register_webhook.md) in the Breez SDK, replacing the `PUSH_TOKEN` with the mobile push token. Once the NDS has received such request it will send a push notification to the corresponding device. +This is the same format used when [registering a webhook](using_webhooks.md) in the Breez SDK, replacing the `` with the mobile push token. Once the NDS has received such request it will send a push notification to the corresponding device. ## Mobile push token Ensure that your mobile application is set up to receive push notifications and can generate a push token. This token uniquely identifies the device for push notifications.