2024-03-14 17:34:23 +01:00
2024-03-02 19:10:14 +01:00
2024-03-02 19:10:14 +01:00
2024-03-02 19:10:14 +01:00
2024-03-05 18:02:17 +01:00

StoneRed.NetificationApi

A .NET library for NotificationAPI

This is an unofficial library for NotificationAPI and attempts to replicate the functionality of the official Server SDK and JS Client SDK as closely as possible.
(A prebuilt notification widget is not included in this library.)

Supported Features

Server:

  • Send all types of notifications
  • Retract notifications
  • Identify user
  • Set user preferences

Client:

  • Receive In-App notification
  • Get old notifications
  • Get unread notification count
  • Clear unread notifications
  • Get user preferences
  • Update user preferences

Installation

Package Manager

Install-Package StoneRed.NetificationApi

.NET CLI

dotnet add package StoneRed.NetificationApi

Usage

Server

using StoneRed.NetificationApi.Server;
using StoneRed.NetificationApi.Server.Send;

// Initialize NotificationApiServer
NotificationApiServer notificationApiServer = new NotificationApiServer("<ClientId>", "<ClientSecret>", secureMode: false);

// Construct notification
SendNotificationData sendNotificationData = new SendNotificationData
{
    NotificationId = "<NotificationId>",
    User = new NotificationUser
    {
        Id = "<UserId>",
    }
};

// Send notification
await notificationApiServer.Send(sendNotificationData);

Client

using StoneRed.NetificationApi.Client;
using StoneRed.NetificationApi.Client.Models;

// The client is used to receive notifications
NotificationApiClient notificationApiClient = new NotificationApiClient("<UserId>", "<ClientId>");

// Listen for new notifications
notificationApiClient.NewNotificationsReceived += (sender, args) =>
{
    Console.WriteLine("New notifications received");
    foreach (NotificationReceivedData notificationReceiveData in args.Notifications)
    {
        Console.WriteLine($"New notification received: {notificationReceiveData.Id}");
    }
};

// Listen for unread count
notificationApiClient.UnreadCountReceived += (sender, args) =>
{
    Console.WriteLine($"Unread count received: {args.Count}");
};

// Request unread count
notificationApiClient.RequestUnreadCount();

For a more sophisticated example, please check out this example.

Third party licenses

S
Description
A .NET library for NotificationAPI
Readme MIT
91 KiB
2024-03-14 17:41:57 +01:00
Languages
C# 100%