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
+37-22Lines changed: 37 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,6 +74,41 @@ Useful links:
74
74
If you want to use Firebase to send iOS notifications, please checkout this article: https://firebase.google.com/docs/cloud-messaging/ios/certs.
75
75
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.
76
76
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
+
77
112
# Apple Push Notifications
78
113
79
114
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:
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.
93
128
Tip: To send properties like {"content-available": true} you can use Newtonsoft.Json attributes over C# properties like `[JsonProperty("content-available")]`.
94
129
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:
97
132
98
133
```csharp
99
-
publicclassGoogleNotification
100
-
{
101
-
publicclassDataPayload
102
-
{
103
-
// Add your custom properties as needed
104
-
[JsonProperty("message")]
105
-
publicstringMessage { get; set; }
106
-
}
107
-
108
-
[JsonProperty("priority")]
109
-
publicstringPriority { get; set; } ="high";
110
-
111
-
[JsonProperty("data")]
112
-
publicDataPayloadData { get; set; }
113
-
}
114
-
115
134
publicclassAppleNotification
116
135
{
117
136
publicclassApsPayload
@@ -128,10 +147,6 @@ public class AppleNotification
128
147
```
129
148
Use `[JsonProperty("alert-type")]` attribute to serialize C# properties into JSON properties with dashes.
130
149
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!).
0 commit comments