You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
10
10
@@ -25,13 +25,15 @@ Package Manager Console:
25
25
Install-Package CorePush
26
26
```
27
27
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
+
28
30
# Firebase Cloud Messages for Android, iOS and Web
29
31
30
32
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.
32
34
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.
33
35
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.
35
37
36
38
Sending messages is very simple so long as you know the format:
**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.
100
102
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")]`.
103
105
104
106
## Example of notification payload
105
107
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
109
111
{
110
112
publicclassApsPayload
111
113
{
112
-
[JsonProperty("alert")]
114
+
[JsonPropertyName("alert")]
113
115
publicstringAlertBody { get; set; }
114
116
}
115
117
116
118
// Your custom properties as needed
117
119
118
-
[JsonProperty("aps")]
120
+
[JsonPropertyName("aps")]
119
121
publicApsPayloadAps { get; set; }
120
122
}
121
123
```
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.
0 commit comments