Skip to content

HTML5 Notifications API implementation for Microsoft Blazor

License

Notifications You must be signed in to change notification settings

DanielCarmingham/Notifications

 
 

Repository files navigation

Notifications

Implementation of the Notification API in C# for Microsoft Blazor.

Build status Package Version NuGet Downloads License

Blazor Extensions

Blazor Extensions are a set of packages with the goal of adding useful things to Blazor.

Installation

Install-Package Blazor.Extensions.Notifications

Demo

There is a sample application in /tests/ folder For some other references of what the API does see the example demo

Usage

Add INotificationService via DI

Scoped by default.

public void ConfigureServices(IServiceCollection services)
{
    services.AddNotifications();
}

Inject into component/pages

@using Blazor.Extensions
@inject INotificationService NotificationService

or

Inject on a BlazorComponent class:

[Inject] private INotificationService _notificationService { get; set; }

Create a notification

NotificationOptions options = new NotificationOptions
{
    Body = body,
    Icon = icon,
};

await NotificationService.CreateAsync(title, options);

Browser Support

bool IsSupportedByBrowser = NotificationService.IsSupportedByBrowserAsync(); 

Request Permission

PermissionType permission = await NotificationService.RequestPermissionAsync();

Contributions and feedback

Please feel free to use the component, open issues, fix bugs or provide feedback.

Contributors

This project is created and maintained by:

The following people are the maintainers of the Blazor Extensions projects:

About

HTML5 Notifications API implementation for Microsoft Blazor

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 57.2%
  • HTML 25.3%
  • CSS 9.3%
  • TypeScript 6.3%
  • JavaScript 1.9%