Skip to content

Commit 0b59282

Browse files
committed
Update the ReadMe file to introduce the basic configuration and usage of the notification service
1 parent b05fb66 commit 0b59282

1 file changed

Lines changed: 57 additions & 2 deletions

File tree

README.md

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,63 @@ This module integrates web push notification services into applications using th
99
# Getting Started
1010
To implement this module in your ABP framework application, @<Lexuan Zhou> TBD... Ensure to configure the necessary dependencies and integrate the service with your application's frontend and backend.
1111

12-
# Contribution
12+
# Configuration
13+
Step 1:
14+
15+
1. Install the [WebPushNotificationService ABP Framework Module](https://github.com/DecisionTreeTechnology/WebPushNotificationService) from Nuget into your project
16+
17+
2. Add DependsOn(typeof(WebPushxxxModule)) attribute to configure the module dependencies.
18+
19+
3. Add ```builder.ConfigureWebPush();``` to the OnModelCreating() method in ```MyProjectMigrationsDbContext.cs```.
20+
21+
4. Add EF Core migrations and update your database. The service will rely on three table to retrive and push notifications: ```WebPushContents```, ```WebPushSubscriptions``` and ```WebPushNotifications```
22+
23+
24+
Step 2:
25+
26+
A pair of VAPID key is needed for the system (what is [VAPID Key](https://stackoverflow.com/questions/40392257/what-is-vapid-and-why-is-it-useful) 🤔). There are multiple ways to generate them.
27+
28+
For Angular:
29+
30+
- Install the [web-push](https://www.npmjs.com/package/web-push) package from NPM by running ```npm install web-push -g```
31+
- Generate the vapid keys by running ```web-push generate-vapid-keys [--json]```. An example of a pair of VAPID Keys would be
32+
33+
```
34+
Public Key:
35+
BFwNomlUWWD2-wDR1cLhPQOxFskYDuUmseG_Pvi2DWI8eMMQuQufq27cQWa_tpO9sGK-AxRrKLdM2YLtdHTW1Dc
36+
37+
Private Key:
38+
Ycpv7MDLJpB9512dZoQ6m2puX6tlnhMoKVtydY0Lz94
39+
```
40+
41+
42+
Step 3:
43+
44+
Set up the configuration by putting the pair of VAPID Keys into your application appsettings.json file. The structure of the key value pair would be as follow:
45+
46+
```
47+
"WebPush": {
48+
"VapidKeys": {
49+
"PublicKey": "YOUR-PUBLIC-KEY",
50+
"PrivateKey": "YOUR-PUBLIC-KEY"
51+
},
52+
"Email": "YOUR-EMAIL"
53+
}
54+
```
55+
56+
# Usuage
57+
Create a ETO (event trasfer object) and push it to the event bus and it will handle the notification queue under the hood
58+
```
59+
var pushNotificationEto =
60+
new CreateWebPushNotificationEto(CurrentTenant.Id, new List<Guid>{createMessageInput.ToUserId}, createMessageInput.Subject,
61+
null, null, null, null, new DateTime?(), null);
62+
await _distributedEventBus.PublishAsync(pushNotificationEto);
63+
```
64+
65+
66+
67+
1368
Contributions are welcome! If you have suggestions or improvements, please fork the repository and submit a pull request.
1469

1570
# License
16-
This project is licensed under the MIT License - see the LICENSE file for details.
71+
This project is licensed under the MIT License - see the LICENSE file for details.

0 commit comments

Comments
 (0)