Skip to content

Commit 2f582b3

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

File tree

1 file changed

+37
-22
lines changed

1 file changed

+37
-22
lines changed

README.md

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,41 @@ Useful links:
7474
If you want to use Firebase to send iOS notifications, please checkout this article: https://firebase.google.com/docs/cloud-messaging/ios/certs.
7575
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.
7676

77+
## Firebase Notification Payload Example
78+
79+
```json
80+
{
81+
"message":{
82+
"token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvD this is DEVICE_TOKEN",
83+
"notification":{
84+
"title":"Match update",
85+
"body":"Arsenal goal in added time, score is now 3-0"
86+
},
87+
"android":{
88+
"ttl":"86400s",
89+
"notification"{
90+
"click_action":"OPEN_ACTIVITY_1"
91+
}
92+
},
93+
"apns": {
94+
"headers": {
95+
"apns-priority": "5",
96+
},
97+
"payload": {
98+
"aps": {
99+
"category": "NEW_MESSAGE_CATEGORY"
100+
}
101+
}
102+
},
103+
"webpush":{
104+
"headers":{
105+
"TTL":"86400"
106+
}
107+
}
108+
}
109+
}
110+
```
111+
77112
# Apple Push Notifications
78113

79114
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:
@@ -92,26 +127,10 @@ await apn.SendAsync(notification, deviceToken);
92127
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.
93128
Tip: To send properties like {"content-available": true} you can use Newtonsoft.Json attributes over C# properties like `[JsonProperty("content-available")]`.
94129

95-
## Examples of notification payload
96-
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 and Android:
130+
## Example of notification payload
131+
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:
97132

98133
```csharp
99-
public class GoogleNotification
100-
{
101-
public class DataPayload
102-
{
103-
// Add your custom properties as needed
104-
[JsonProperty("message")]
105-
public string Message { get; set; }
106-
}
107-
108-
[JsonProperty("priority")]
109-
public string Priority { get; set; } = "high";
110-
111-
[JsonProperty("data")]
112-
public DataPayload Data { get; set; }
113-
}
114-
115134
public class AppleNotification
116135
{
117136
public class ApsPayload
@@ -128,10 +147,6 @@ public class AppleNotification
128147
```
129148
Use `[JsonProperty("alert-type")]` attribute to serialize C# properties into JSON properties with dashes.
130149

131-
# Known Issues
132-
133-
* Doesn't seem like it's running on Mono [#55](https://github.com/andrei-m-code/net-core-push-notifications/issues/55) (Help Wanted!).
134-
135150
# MIT License
136151

137152
Copyright (c) 2020 Andrei M

0 commit comments

Comments
 (0)