Skip to content
This repository has been archived by the owner on Jan 4, 2020. It is now read-only.

Chapnik13/PushNotification

Repository files navigation

éöéøú NotificationHub òí îúåãä SendNotification
éöéøú INotificationClient òí îúåãä GetNotification
ùúéäï öøéëåú ìäçæéø Task!!

ìäâãéø áStartup  services.AddSignalR();
ìäâãéø áStartup endpoint ìnotificationHub

ìäåñéó NotificationService ùéäéä BackgroundService
é÷áì IHubContext<NotificationHub, INotificationClient>
åéùìç äåãòä ëì ëîä ùðéåú


öã ì÷åç
ìäú÷éï çáéìä @aspnet/signalr
ìäåñéó service
ng g service NotificationService

ìäòúé÷ ÷åã
export class NotificationService {

  private hubConnection: HubConnection;

  public async connect() {
    this.hubConnection = new HubConnectionBuilder()
      .withUrl("/notificationHub")
      .configureLogging(LogLevel.Information)
      .build();

    await this.hubConnection.start();
  }

  public addNotificationListener() {
    this.hubConnection.on('GetNotification', (data) => {
      Notification.requestPermission(function (premission) {
        var notification = new Notification("Title", { body: data });
      });
    });
  }

  public sendNotification(message: string) {
    this.hubConnection.send("SendNotification", message);
  }

}


áApp.Component.ts ìäåñéó àú äconnect åäaddNotificationListener

ng g component send-notification --module app
<button (click)="sendMessage()">Send Message</button>
ìéöåø îúåãä ùúùìç äåãòä

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published