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
Copy file name to clipboardExpand all lines: README.md
+10-14Lines changed: 10 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,28 +23,24 @@ Install-Package CorePush
23
23
For Firebase messages we will need project Server Key and Sender ID. To find Server Key and Sender ID go to Firebase Console (https://console.firebase.google.com), select your project, then go to project settings -> cloud messaging. You should be able to find everything you need there. Here is a simple example of how you send Firebase notification:
24
24
25
25
```csharp
26
-
using (varfcm=newFcmSender(serverKey, senderId))
27
-
{
28
-
awaitfcm.SendAsync(deviceToken, notification);
29
-
}
26
+
varfcm=newFcmSender(settings, httpClient);
27
+
awaitfcm.SendAsync(deviceToken, notification);
30
28
```
31
29
If you want to use Firebase to send iOS notifications, please checkout this article: https://firebase.google.com/docs/cloud-messaging/ios/certs.
32
30
The library serializes notification object to JSON using Newtonsoft.Json library and sends it to Google cloud. Here is more details on the expected payloads for FCM https://firebase.google.com/docs/cloud-messaging/concept-options#notifications. Please note, we are setting the "to" property to use device token, so you don't have to do it yourself.
33
31
34
32
## Apple Push Notifications
35
33
36
-
To send notifications to Apple devices you have to create a publisher profile and pass necessary parameters to ApnSender constructor. Apn Sender will create and sign JWT token and attach it to every request to Apple servers:
37
-
1.p8privateKey - p8 certificate generated in itunes. Just 1 line string without spaces, ----- or line breaks.
38
-
2.privateKeyId - 10 digit p8 certificate id. Usually a part of a downloadable certificate filename e.g. AuthKey_IDOFYOURCR.p8</param>
39
-
3.teamId - Apple 10 digit team id from itunes
40
-
4.appBundleIdentifier - App slug / bundle name e.g.com.myawesomecompany.helloworld
41
-
5.server - Development or Production APN server
34
+
To send notifications to Apple devices you have to create a publisher profile and pass settings object with necessary parameters to ApnSender constructor. Apn Sender will create and sign JWT token and attach it to every request to Apple servers:
35
+
1.P8 private key - p8 certificate generated in itunes. Just 1 line string without spaces, ----- or line breaks.
36
+
2.Private key id - 10 digit p8 certificate id. Usually a part of a downloadable certificate filename e.g. AuthKey_IDOFYOURCR.p8</param>
37
+
3.Team id - Apple 10 digit team id from itunes
38
+
4.App bundle identifier - App slug / bundle name e.g.com.myawesomecompany.helloworld
39
+
5.Server type - Development or Production APN server
42
40
43
41
```csharp
44
-
using (varapn=newApnSender(p8privateKey, p8privateKeyId, teamId, appBundleIdentifier, server))
45
-
{
46
-
awaitapn.SendAsync(notification, deviceToken);
47
-
}
42
+
varapn=newApnSender(settings, httpClient);
43
+
awaitapn.SendAsync(notification, deviceToken);
48
44
```
49
45
**IMPORTANT**: Initialize 1 ApnSender per bundle, send messages and don't forget to dispose your object. 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.
0 commit comments