Using Webhooks

Registering a Webhook

Once your vendor NDS is set up and can accept POST requests from the SDK services, you can within your main application register the webhook URL with the Breez SDK by calling the register webhook API as follows:

Rust
let url = "https://your-nds-service.com/notify?platform=<ios|android>&token=<PUSH_TOKEN>".to_string();
sdk.register_webhook(url).await?;
Swift
let url = "https://your-nds-service.com/notify?platform=<ios|android>&token=<PUSH_TOKEN>"
try sdk.registerWebhook(webhookUrl: url)  
Kotlin
try {
    val url = "https://your-nds-service.com/notify?platform=<ios|android>&token=<PUSH_TOKEN>"
    sdk.registerWebhook(url)
} catch (e: Exception) {
    // Handle error
}
React Native
try {
  const url = 'https://your-nds-service.com/notify?platform=<ios|android>&token=<PUSH_TOKEN>'
  await registerWebhook(url)
} catch (err) {
  console.error(err)
}
Dart
String url = "https://your-nds-service.com/notify?platform=<ios|android>&token=<PUSH_TOKEN>";
await breezSDK.registerWebhook(webhookUrl: url);
Python
url = "https://your-nds-service.com/notify?platform=<ios|android>&token=<PUSH_TOKEN>"
sdk_services.register_webhook(url)
Go
url := "https://your-nds-service.com/notify?platform=<ios|android>&token=<PUSH_TOKEN>"
if err := sdk.RegisterWebhook(url); err != nil {
    log.Printf("Webhook register failed: %v", err)
}
C#
try
{
    var url = "https://your-nds-service.com/notify?platform=<ios|android>&token=<PUSH_TOKEN>";
    sdk.RegisterWebhook(url);
}
catch (Exception)
{
    // Handle error
}

When the NDS receives a POST request for the registered webhook URL, it will forward the request data via push notification to the applications Service Extension (iOS) or Foreground Service (Android) to be handled by the Notification Plugin.

Unregistering a Webhook

When a webhook is no longer needed or the webhook URL has changed such that it needs unregistering (for example, the token is valid but the locale changes), you can call the unregister webhook API as follows:

Rust
let url = "https://your-nds-service.com/notify?platform=<ios|android>&token=<PUSH_TOKEN>".to_string();
sdk.unregister_webhook(url).await?;
Swift
let url = "https://your-nds-service.com/notify?platform=<ios|android>&token=<PUSH_TOKEN>"
try sdk.unregisterWebhook(webhookUrl: url)  
Kotlin
try {
    val url = "https://your-nds-service.com/notify?platform=<ios|android>&token=<PUSH_TOKEN>"
    sdk.unregisterWebhook(url)
} catch (e: Exception) {
    // Handle error
}
React Native
try {
  const url = 'https://your-nds-service.com/notify?platform=<ios|android>&token=<PUSH_TOKEN>'
  await unregisterWebhook(url)
} catch (err) {
  console.error(err)
}
Dart
String url = "https://your-nds-service.com/notify?platform=<ios|android>&token=<PUSH_TOKEN>";
await breezSDK.unregisterWebhook(webhookUrl: url);
Python
url = "https://your-nds-service.com/notify?platform=<ios|android>&token=<PUSH_TOKEN>"
sdk_services.unregister_webhook(url)
Go
url := "https://your-nds-service.com/notify?platform=<ios|android>&token=<PUSH_TOKEN>"
if err := sdk.UnregisterWebhook(url); err != nil {
    log.Printf("Webhook unregister failed: %v", err)
}
C#
try
{
    var url = "https://your-nds-service.com/notify?platform=<ios|android>&token=<PUSH_TOKEN>";
    sdk.UnregisterWebhook(url);
}
catch (Exception)
{
    // Handle error
}