Starts in:
2 DAYS
10 HRS
20 MIN
8 SEC
Starts in:
2 D
10 H
20 M
8 S
Open Closed

Push Notifications #612


User avatar
0
lalitChougule created
  • ABP Framework version: v3.0.4
  • UI type: Angular
  • Tiered (MVC) or Identity Server Seperated (Angular): no / yes
  • Exception message and stack trace: N.A
  • Steps to reproduce the issue: N.A

Hi,

I want to implement Push notification in my application

for example myCart , If my user add anything in cart the count or badge number increases on the bell icon and customer receives a notification where there is a small message xyz product is added into your cart.

Document below just give only the idea how to integrate SignalR and that too on the API side not on Angular side. https://docs.abp.io/en/abp/3.1/SignalR-Integration

Please provide if any example is available.

Thanks


1 Answer(s)
  • User Avatar
    0
    alper created
    Support Team Director

    hi,

    you can see Event Bus system. By Event Bus, you can register to your card insert event and the subscriber class can send the data to the client via SignalR.

    and I can share a sample code to init SignalR connection in the Angular side

    import * as signalR from '@microsoft/signalr';

     private initSignalR(currentUser: ApplicationConfiguration.CurrentUser) {
        if (this.conectedUserId === currentUser.id) return;
        if (this.connection) this.connection.stop();
    
        this.connection = new signalR.HubConnectionBuilder()
          .withUrl(`${this.signalRUrl}/signalr-hubs/chat`, {
            accessTokenFactory: () => this.oAuthService.getAccessToken(),
          })
          .build();
    
        this.connection.on('ReceiveMessage', this.handleMessage);
    
        this.connection
          .start()
          .then(() => {
            this.conectedUserId = currentUser.id;
          })
          .catch((err) => {
            return console.error(err.toString());
          });
      }
    

    Also see the usage from https://www.npmjs.com/package/@microsoft/signalr

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06