Skip to content

Commit a8bdf6f

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 71a4414 + 237b9c8 commit a8bdf6f

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
# .NET Core Push Notifications for Web, Android and iOS
44
Send notifications to:
5-
-**iOS** - Apple Push Notifications (APN)
6-
-**Android** - via Firebase Cloud Messaging (FCM)
7-
-**Web** - via Firebase Cloud Messaging (FCM)
5+
-**iOS** - Apple Push Notifications (via Latest Apple Push Notifications HTTP2 JWT API)
6+
-**Android** - via Firebase Cloud Messaging (via Latest Firebase HTTP v1 API)
7+
-**Web** - via Firebase Cloud Messaging (via Latest Firebase HTTP v1 API)
88

99
CorePush is a simple lightweight library with minimal overhead. Send notifications to Android and Web using Firebase Cloud Messaging and iOS APN with JWT HTTP/2 API.
1010

@@ -25,13 +25,15 @@ Package Manager Console:
2525
Install-Package CorePush
2626
```
2727

28+
Check out Tester project [Program.cs](https://github.com/andrei-m-code/net-core-push-notifications/blob/master/CorePush.Tester/Program.cs) for a quick getting started.
29+
2830
# Firebase Cloud Messages for Android, iOS and Web
2931

3032
To start sending Firebase messages you need to have Google Project ID and JWT Bearer token. Steps to generate JWT bearer token:
31-
1. Enable HTTP v1 API if you haven't done it yet. Go here for instructions: https://console.firebase.google.com/project/[YOUR_GOOGLE_PROJECT_ID e.g. my-project-123456]/settings/cloudmessaging/
33+
1. Enable HTTP v1 API if you haven't done it yet. Go here for instructions: https://console.firebase.google.com/project/YOUR-GOOGLE-PROJECT-ID/settings/cloudmessaging/ Your project ID looks like this: my-project-123456.
3234
2. From that page you can also go to "Manage Service Accounts". Here is the link: https://console.cloud.google.com/iam-admin/serviceaccounts and select your project.
3335
3. Create Service Account with "Firebase Service Management Service Agent" role.
34-
4. Download Service Account JSON file and use it to configure FirebaseSender.
36+
4. Download Service Account JSON file and use it to configure FirebaseSender either by deserializing it into FirebaseSettings or by directly passing json string into the constructor.
3537

3638
Sending messages is very simple so long as you know the format:
3739

@@ -98,8 +100,8 @@ await apn.SendAsync(notification, deviceToken);
98100
```
99101
**IMPORTANT**: Initialize 1 ApnSender per bundle. When you send many messages at once make sure to retry the sending in case of an error. If error happens it's recommended to retry the call after 1 second delay (await Task.Delay(1000)). Apple typically doesn't like to receive too many messages and will ocasionally respond with HTTP 429. From my experiance it happens once per 1000 requests.
100102

101-
Please see Apple notification format examples here: https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH10-SW1.
102-
Tip: To send properties like {"content-available": true} you can use Newtonsoft.Json attributes over C# properties like `[JsonProperty("content-available")]`.
103+
Please see Apple notification payload examples here: https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH10-SW1.
104+
Tip: To send properties like {"content-available": true} you can use System.Text.Json attributes over C# properties like `[JsonPropertyName("content-available")]`.
103105

104106
## Example of notification payload
105107
You can find expected notification formats for different types of notifications in the documentation. To make it easier to get started, here is a simple example of visible notification (the one that you'll see in phone's notification center) for iOS:
@@ -109,17 +111,17 @@ public class AppleNotification
109111
{
110112
public class ApsPayload
111113
{
112-
[JsonProperty("alert")]
114+
[JsonPropertyName("alert")]
113115
public string AlertBody { get; set; }
114116
}
115117

116118
// Your custom properties as needed
117119
118-
[JsonProperty("aps")]
120+
[JsonPropertyName("aps")]
119121
public ApsPayload Aps { get; set; }
120122
}
121123
```
122-
Use `[JsonProperty("alert-type")]` attribute to serialize C# properties into JSON properties with dashes.
124+
Use `[JsonPropertyName("alert-type")]` attribute to serialize C# properties into JSON properties with dashes.
123125

124126
# MIT License
125127

0 commit comments

Comments
 (0)