Skip to content

Commit d608769

Browse files
Update README.md
1 parent 2f582b3 commit d608769

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

README.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,6 @@ Package Manager Console:
2424
Install-Package CorePush
2525
```
2626

27-
## Setup for ASP.NET Core with Dependency Injection
28-
29-
Both `ApnSender` and `FirebaseSender` have dependencies that need to be registered in order to enable DI.
30-
31-
1. Register HttpClient in Startup.cs. This will allow injection of HttpClient into the FCM and APN senders:
32-
33-
```
34-
services.AddHttpClient<FirebaseSender>();
35-
services.AddHttpClient<ApnSender>();
36-
```
37-
38-
2. Register settings object as a singleton:
39-
40-
If you've added ApnSettings and FcmSettings into a configuration section, you can bind section directly to settings object from `IConfiguration` available in Startup.cs:
41-
42-
```
43-
var section = configuration.GetSection("ApnSettings");
44-
var settings = new AppSettings();
45-
section.Bind(settings);
46-
```
47-
48-
Add settings to services:
49-
```
50-
services.AddSingleton(apnSettings);
51-
services.AddSingleton(fcmSettings);
52-
```
53-
5427
# Firebase Cloud Messages for Android, iOS and Web
5528

5629
To start sending Firebase messages you need to have Google Project ID and JWT Bearer token. Steps to generate JWT bearer token:
@@ -147,6 +120,33 @@ public class AppleNotification
147120
```
148121
Use `[JsonProperty("alert-type")]` attribute to serialize C# properties into JSON properties with dashes.
149122

123+
# Setup for ASP.NET Core with Dependency Injection
124+
125+
Both `ApnSender` and `FirebaseSender` have dependencies that need to be registered in order to enable DI.
126+
127+
1. Register HttpClient in Startup.cs. This will allow injection of HttpClient into the FCM and APN senders:
128+
129+
```
130+
services.AddHttpClient<FirebaseSender>();
131+
services.AddHttpClient<ApnSender>();
132+
```
133+
134+
2. Register settings object as a singleton:
135+
136+
If you've added `ApnSettings` and `FirebaseSettings` into a configuration section, you can bind section directly to settings object from `IConfiguration` available in Startup.cs:
137+
138+
```
139+
var section = configuration.GetSection("ApnSettings");
140+
var settings = new AppSettings();
141+
section.Bind(settings);
142+
```
143+
144+
Add settings to services:
145+
```
146+
services.AddSingleton(apnSettings);
147+
services.AddSingleton(fcmSettings);
148+
```
149+
150150
# MIT License
151151

152152
Copyright (c) 2020 Andrei M

0 commit comments

Comments
 (0)