BccCode.Notifications.Client 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package BccCode.Notifications.Client --version 1.0.2
                    
NuGet\Install-Package BccCode.Notifications.Client -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BccCode.Notifications.Client" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BccCode.Notifications.Client" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="BccCode.Notifications.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BccCode.Notifications.Client --version 1.0.2
                    
#r "nuget: BccCode.Notifications.Client, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BccCode.Notifications.Client@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BccCode.Notifications.Client&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=BccCode.Notifications.Client&version=1.0.2
                    
Install as a Cake Tool

BCC Notifications .NET Client

A professional-grade .NET client for the BCC Notifications API, built entirely on BCC Platform services following the exact same patterns as BccCode.PubSub.Client.

🚀 Key Features

  • Platform-First Architecture: Built on BccCode.Platform.Apis and BccCode.Platform.Auth
  • Multiple Setup Options: Supports platform defaults, custom environments, and direct configuration
  • Scope-Based Authentication: Automatic OAuth token management with proper scopes
  • Consistent API: Follows exact same patterns as other BCC clients (PubSub, Core API, etc.)
  • Full Feature Support: Email (with attachments), SMS, and In-App notifications
  • Enterprise-Grade: Built-in retries, proper error handling, and comprehensive logging

📦 Installation

dotnet add package BccCode.Notifications.Client

Prerequisites

This package depends on BccCode.Platform packages which are hosted on BCC's internal NuGet feed. You'll need to configure access to the internal feed:

  1. Add BCC Internal NuGet Source to your nuget.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
    <add key="bcc-internal" value="[BCC_INTERNAL_NUGET_URL]" />
  </packageSources>
  <packageSourceCredentials>
    <bcc-internal>
      <add key="Username" value="[YOUR_USERNAME]" />
      <add key="ClearTextPassword" value="[YOUR_TOKEN]" />
    </bcc-internal>
  </packageSourceCredentials>
</configuration>
  1. Contact your BCC Platform team to get:
    • Internal NuGet feed URL
    • Authentication credentials/token

⚡ Setup Options

// Configure BCC Platform first
services.AddBccPlatform(options =>
{
    options.Environment = AppEnvironment.Development; // or Production
    options.OAuth.ClientId = "your-client-id";
    options.OAuth.ClientSecret = "your-client-secret";
});

// Add notifications client - automatically uses platform configuration
services.AddBccNotifications();

Option 2: Environment + Credentials

// Self-contained setup
services.AddBccNotifications(
    AppEnvironment.Development,
    new OAuthCredentials("client-id", "client-secret")
);

Option 3: Custom Configuration

// Full control over configuration
services.AddBccNotifications(
    "https://api.custom-environment.bcc.no",
    new OAuthOptions
    {
        ClientId = "your-client-id",
        ClientSecret = "your-client-secret",
        Scope = "notifications#send"
    }
);

Option 4: Advanced (Custom Auth Provider)

// Using custom authentication
services.AddBccNotifications(
    AppEnvironment.Production,
    customAuthHeaderProvider
);

🔥 Usage Examples

Email with Attachments

var client = serviceProvider.GetRequiredService<INotificationClient>();

var emailRequest = new EmailNotificationRequest
{
    PersonUid = userId,
    NotificationPayload = new List<EmailContent>
    {
        new()
        {
            Language = "en-US",
            Subject = "Documents Attached",
            Content = "Please find your documents: <img src=\"cid:logo\">",
            Attachments = new List<EmailAttachment>
            {
                EmailAttachment.FromFile("/path/to/document.pdf"),
                EmailAttachment.FromBytes("logo.png", imageBytes, "image/png", 
                    contentId: "logo", isInline: true)
            }
        }
    }
};

var response = await client.SendEmailAsync(emailRequest);

Multi-Language SMS

var smsRequest = new SmsNotificationRequest
{
    GroupUid = groupId,
    NotificationPayload = new List<SmsContent>
    {
        new() { Language = "en-US", Content = "Hello [firstName]!" },
        new() { Language = "no-NO", Content = "Hei [firstName]!" }
    }
};

var response = await client.SendSmsAsync(smsRequest);

In-App with Call-to-Action

var inAppRequest = new InAppNotificationRequest
{
    PersonUid = userId,
    NotificationPayload = new List<InAppContent>
    {
        new()
        {
            Language = "en-US",
            Title = "New Feature!",
            Content = "Try our new feature: [cta text=\"Get Started\" link=\"https://portal.bcc.no\"]"
        }
    }
};

var response = await client.SendInAppAsync(inAppRequest);

🏗️ Platform Integration

Authentication Scopes

The client automatically handles OAuth scopes:

  • notifications#send - For sending notifications
  • notifications#admin - For administrative operations

Environment Support

Built-in support for BCC environments:

  • AppEnvironment.Development
  • AppEnvironment.Staging
  • AppEnvironment.Production

Error Handling

try
{
    var response = await client.SendEmailAsync(request);
    Console.WriteLine($"✅ Sent: {response.Id}");
}
catch (NotificationApiException ex)
{
    Console.WriteLine($"❌ API Error [{ex.StatusCode}]: {ex.Message}");
    Console.WriteLine($"Response: {ex.ResponseContent}");
}

🔄 Migration from Previous Versions

Backward Compatibility

All existing code continues to work with deprecation warnings:

// Old method (still works, but shows warning)
services.AddNotificationClient();

// New recommended method
services.AddBccNotifications();

Update Pattern

// Before
services.AddNotificationClient(options =>
{
    options.Environment = NotificationEnvironment.Development;
});

// After
services.AddBccNotifications(
    AppEnvironment.Development,
    new OAuthCredentials("client-id", "client-secret")
);

All use:

  • IAuthHeaderProvider for authentication
  • PlatformOptions and AppEnvironment for configuration
  • Scope-based OAuth authentication
  • Consistent error handling patterns

🛠️ Architecture

Dependency Graph

BccCode.Notifications.Client
├── BccCode.Platform.Apis (authentication, HTTP management)
├── BccCode.Platform.Auth (OAuth providers)
├── BccCode.Notifications.Contracts (models)
├── Newtonsoft.Json (serialization)
└── Microsoft.Extensions.Logging.Abstractions

Authentication Flow

  1. Client requests scope: notifications#send
  2. IAuthHeaderProvider obtains OAuth token
  3. HTTP requests include Authorization: Bearer {token}
  4. Automatic token refresh on expiration

Test comment for automation

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.3.2 319 6/25/2025
2.3.1 137 6/25/2025
2.2.1 166 6/24/2025
2.0.2 165 6/19/2025
2.0.1 139 6/19/2025
1.0.2 286 6/12/2025
1.0.1 283 6/12/2025