Skip to content

Commit

Permalink
Small cleanup before nuget
Browse files Browse the repository at this point in the history
  • Loading branch information
galvesribeiro committed Oct 30, 2018
1 parent e0ea35d commit 3e33833
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .vsts-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ steps:
- task: NuGetCommand@2
inputs:
command: push
packagesToPush: '$(build.artifactStagingDirectory)/*.nupkg'
packagesToPush: '$(build.ArtifactStagingDirectory)/**/*.nupkg;!$(build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
publishFeedCredentials: 'BlazorExtensions'
nuGetFeedType: external
versioningScheme: byEnvVar
Expand Down
48 changes: 41 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
# Notifications
Implementation of the [Notification API](https://developer.mozilla.org/en-US/docs/Web/API/notification) in C# for [Blazor](https://github.com/aspnet/Blazor) via Interop.
Implementation of the [Notification API](https://developer.mozilla.org/en-US/docs/Web/API/notification) in C# for [Microsoft Blazor](https://github.com/aspnet/Blazor).

## Demo
There is a sample application in /tests/ folder
For some other references of what the API does see the example [demo](https://web-push-book.gauntface.com/demos/notification-examples/)
[![Build status](https://dotnet-ci.visualstudio.com/DotnetCI/_apis/build/status/Blazor-Extensions-Notifications-CI?branch=master)](https://dotnet-ci.visualstudio.com/DotnetCI/_build/latest?definitionId=8&branch=master)
[![Package Version](https://img.shields.io/nuget/v/Blazor.Extensions.Notifications.svg)](https://www.nuget.org/packages/Blazor.Extensions.Notifications)
[![NuGet Downloads](https://img.shields.io/nuget/dt/Blazor.Extensions.Notifications.svg)](https://www.nuget.org/packages/Blazor.Extensions.Notifications)
[![License](https://img.shields.io/github/license/BlazorExtensions/Notifications.svg)](https://github.com/BlazorExtensions/Notifications/blob/master/LICENSE)

# Blazor Extensions

Blazor Extensions are a set of packages with the goal of adding useful things to [Blazor](https://blazor.net).

## Installation

Coming Soon (waiting on the nuspec/ci)
```
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](https://web-push-book.gauntface.com/demos/notification-examples/)

## Usage

### Add INotificationService via DI
### Add `INotificationService` via DI
> Scoped by default.
```csharp
public void ConfigureServices(IServiceCollection services)
Expand All @@ -26,6 +37,14 @@ public void ConfigureServices(IServiceCollection services)
@inject INotificationService NotificationService
```

or

### Injhect on a `BlazorComponent` class:

```c#
[Inject] private INotificationService _notificationService { get; set; }
```

### Create a notification
```csharp
NotificationOptions options = new NotificationOptions
Expand All @@ -38,9 +57,24 @@ await NotificationService.CreateAsync(title, options);
```
### Browser Support
```csharp
bool IsSupportedByBrowser = NotificationService.IsSupportedByBrowserAsync;
bool IsSupportedByBrowser = NotificationService.IsSupportedByBrowserAsync();
```
### Request Permission
```csharp
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:

- [Benjamin Vertonghen](vertonghenb)

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

- [Attila Hajdrik](https://github.com/attilah)
- [Gutemberg Ribiero](https://github.com/galvesribeiro)

Large diffs are not rendered by default.

28 changes: 7 additions & 21 deletions src/Blazor.Extensions.Notifications.JS/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@ interface INotificationsManager {
Create(title: string, options: object): object;
}


export class NotificationsManager implements INotificationsManager {
RequestPermission(): Promise<string> {
public RequestPermission = (): Promise<string> => {
return new Promise((resolve, reject) => {
Notification.requestPermission((permission) => {
resolve(permission);
});
});
}
IsSupported(): boolean {

public IsSupported = (): boolean => {
if (("Notification" in window))
return true;
return false;
}
Create(title: string, options: object): object {

public Create = (title: string, options: object): object => {
var note = new Notification(title, options);
return note;
}
Expand Down
5 changes: 1 addition & 4 deletions src/Blazor.Extensions.Notifications/NotificationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ public async Task<PermissionType> RequestPermissionAsync()
}


public Task CreateAsync(string title, NotificationOptions options)
{
return JSRuntime.Current.InvokeAsync<string>(CreateFunctionName, title, options);
}
public Task CreateAsync(string title, NotificationOptions options) => JSRuntime.Current.InvokeAsync<string>(CreateFunctionName, title, options);

public Task CreateAsync(string title, string body, string icon)
{
Expand Down

0 comments on commit 3e33833

Please sign in to comment.