Skip to content

Commit 189a840

Browse files
authored
Merge branch 'master' into patch-1
2 parents ceb9daf + 864ede0 commit 189a840

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

PushSharp.Apple/ApnsConnection.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ async Task connect ()
354354
(sender, targetHost, localCerts, remoteCert, acceptableIssuers) => certificate);
355355

356356
try {
357-
stream.AuthenticateAsClient (Configuration.Host, certificates, System.Security.Authentication.SslProtocols.Tls, false);
357+
var tls = System.Security.Authentication.SslProtocols.Tls | System.Security.Authentication.SslProtocols.Tls11 | System.Security.Authentication.SslProtocols.Tls12;
358+
stream.AuthenticateAsClient(Configuration.Host, certificates, tls, false);
358359
} catch (System.Security.Authentication.AuthenticationException ex) {
359360
throw new ApnsConnectionException ("SSL Stream Failed to Authenticate as Client", ex);
360361
}

PushSharp.Apple/ApnsFeedbackService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public void Check ()
3838
(sender, cert, chain, sslErrs) => { return true; },
3939
(sender, targetHost, localCerts, remoteCert, acceptableIssuers) => { return certificate; });
4040

41-
stream.AuthenticateAsClient(Configuration.FeedbackHost, certificates, System.Security.Authentication.SslProtocols.Tls, false);
41+
var tls = System.Security.Authentication.SslProtocols.Tls | System.Security.Authentication.SslProtocols.Tls11 | System.Security.Authentication.SslProtocols.Tls12;
42+
stream.AuthenticateAsClient(Configuration.FeedbackHost, certificates, tls, false);
4243

4344

4445
//Set up

README.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PushSharp v4.0
22
==============
33

4-
PushSharp is a server-side library for sending Push Notifications to iOS/OSX (APNS), Android/Chrome (GCM), Windows/Windows Phone, Amazon (ADM) and Blackberry devices!
4+
PushSharp is a server-side library for sending Push Notifications to iOS/OSX (APNS), Android/Chrome (GCM/FCM), Windows/Windows Phone, Amazon (ADM) and Blackberry devices!
55

66
PushSharp v3.0+ is a complete rewrite of the original library, aimed at taking advantage of things like async/await, HttpClient, and generally a better infrastructure using lessons learned from the old code.
77

@@ -102,13 +102,19 @@ fbs.Check ();
102102
```
103103

104104

105-
### GCM Sample Usage
105+
### GCM/FCM Sample Usage
106106

107-
Here is how you would send a GCM Notification:
107+
Here is how you would send a GCM/FCM Notification:
108108

109109
```csharp
110-
// Configuration
110+
// Configuration GCM (use this section for GCM)
111111
var config = new GcmConfiguration ("GCM-SENDER-ID", "AUTH-TOKEN", null);
112+
var provider = "GCM";
113+
114+
// Configuration FCM (use this section for FCM)
115+
// var config = new GcmConfiguration("APIKEY");
116+
// config.GcmUrl = "https://fcm.googleapis.com/fcm/send";
117+
// var provider = "FCM";
112118
113119
// Create a new broker
114120
var gcmBroker = new GcmServiceBroker (config);
@@ -125,18 +131,18 @@ gcmBroker.OnNotificationFailed += (notification, aggregateEx) => {
125131
var gcmNotification = notificationException.Notification;
126132
var description = notificationException.Description;
127133

128-
Console.WriteLine ($"GCM Notification Failed: ID={gcmNotification.MessageId}, Desc={description}");
134+
Console.WriteLine ($"{provider} Notification Failed: ID={gcmNotification.MessageId}, Desc={description}");
129135
} else if (ex is GcmMulticastResultException multicastException) {
130136

131137
foreach (var succeededNotification in multicastException.Succeeded) {
132-
Console.WriteLine ($"GCM Notification Succeeded: ID={succeededNotification.MessageId}");
138+
Console.WriteLine ($"{provider} Notification Succeeded: ID={succeededNotification.MessageId}");
133139
}
134140

135141
foreach (var failedKvp in multicastException.Failed) {
136142
var n = failedKvp.Key;
137143
var e = failedKvp.Value;
138144

139-
Console.WriteLine ($"GCM Notification Failed: ID={n.MessageId}, Desc={e.Description}");
145+
Console.WriteLine ($"{provider} Notification Failed: ID={n.MessageId}, Desc={e.Description}");
140146
}
141147

142148
} else if (ex is DeviceSubscriptionExpiredException expiredException) {
@@ -146,16 +152,16 @@ gcmBroker.OnNotificationFailed += (notification, aggregateEx) => {
146152

147153
Console.WriteLine ($"Device RegistrationId Expired: {oldId}");
148154

149-
if (!string.IsNullOrWhitespace (newId)) {
155+
if (!string.IsNullOrWhiteSpace (newId)) {
150156
// If this value isn't null, our subscription changed and we should update our database
151157
Console.WriteLine ($"Device RegistrationId Changed To: {newId}");
152158
}
153159
} else if (ex is RetryAfterException retryException) {
154160

155161
// If you get rate limited, you should stop sending messages until after the RetryAfterUtc date
156-
Console.WriteLine ($"GCM Rate Limited, don't send more until after {retryException.RetryAfterUtc}");
162+
Console.WriteLine ($"{provider} Rate Limited, don't send more until after {retryException.RetryAfterUtc}");
157163
} else {
158-
Console.WriteLine ("GCM Notification Failed for some unknown reason");
164+
Console.WriteLine ("{provider} Notification Failed for some unknown reason");
159165
}
160166

161167
// Mark it as handled
@@ -164,7 +170,7 @@ gcmBroker.OnNotificationFailed += (notification, aggregateEx) => {
164170
};
165171

166172
gcmBroker.OnNotificationSucceeded += (notification) => {
167-
Console.WriteLine ("GCM Notification Sent!");
173+
Console.WriteLine ("{provider} Notification Sent!");
168174
};
169175

170176
// Start the broker
@@ -186,7 +192,7 @@ foreach (var regId in MY_REGISTRATION_IDS) {
186192
gcmBroker.Stop ();
187193
```
188194

189-
#### Components of a GCM Notification
195+
#### Components of a GCM/FCM Notification
190196

191197
GCM notifications are much more customizable than Apple Push Notifications. More information about the messaging concepts and options can be found [here](https://developers.google.com/cloud-messaging/concept-options#components-of-a-message).
192198

0 commit comments

Comments
 (0)