BccCode.Notifications.Client
1.0.2
There is a newer version of this package available.
See the version list below for details.
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" />
<PackageReference Include="BccCode.Notifications.Client" />
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
#tool nuget:?package=BccCode.Notifications.Client&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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
andBccCode.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:
- 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>
- Contact your BCC Platform team to get:
- Internal NuGet feed URL
- Authentication credentials/token
⚡ Setup Options
Option 1: Platform Defaults (Recommended)
// 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 notificationsnotifications#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 authenticationPlatformOptions
andAppEnvironment
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
- Client requests scope:
notifications#send
IAuthHeaderProvider
obtains OAuth token- HTTP requests include
Authorization: Bearer {token}
- Automatic token refresh on expiration
Test comment for automation
Product | Versions 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.
-
net8.0
- BccCode.Notifications.Contracts (>= 1.0.0)
- BccCode.Platform.Apis (>= 1.0.0.114)
- BccCode.Platform.Config (>= 1.0.0.114)
- Microsoft.Extensions.Http (>= 6.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
- Newtonsoft.Json (>= 13.0.3)
- System.Text.Json (>= 9.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.