Skip to content

Commit

Permalink
💄 Readme Example Code
Browse files Browse the repository at this point in the history
  • Loading branch information
PaitoAnderson authored Aug 10, 2017
1 parent a0dc0ac commit ceb9daf
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ apnsBroker.OnNotificationFailed += (notification, aggregateEx) => {
aggregateEx.Handle (ex => {

// See what kind of exception it was to further diagnose
if (ex is ApnsNotificationException) {
var notificationException = (ApnsNotificationException)ex;
if (ex is ApnsNotificationException notificationException) {

// Deal with the failed notification
var apnsNotification = notificationException.Notification;
Expand Down Expand Up @@ -120,16 +119,14 @@ gcmBroker.OnNotificationFailed += (notification, aggregateEx) => {
aggregateEx.Handle (ex => {

// See what kind of exception it was to further diagnose
if (ex is GcmNotificationException) {
var notificationException = (GcmNotificationException)ex;
if (ex is GcmNotificationException notificationException) {

// Deal with the failed notification
var gcmNotification = notificationException.Notification;
var description = notificationException.Description;

Console.WriteLine ($"GCM Notification Failed: ID={gcmNotification.MessageId}, Desc={description}");
} else if (ex is GcmMulticastResultException) {
var multicastException = (GcmMulticastResultException)ex;
} else if (ex is GcmMulticastResultException multicastException) {

foreach (var succeededNotification in multicastException.Succeeded) {
Console.WriteLine ($"GCM Notification Succeeded: ID={succeededNotification.MessageId}");
Expand All @@ -142,8 +139,7 @@ gcmBroker.OnNotificationFailed += (notification, aggregateEx) => {
Console.WriteLine ($"GCM Notification Failed: ID={n.MessageId}, Desc={e.Description}");
}

} else if (ex is DeviceSubscriptionExpiredException) {
var expiredException = (DeviceSubscriptionExpiredException)ex;
} else if (ex is DeviceSubscriptionExpiredException expiredException) {

var oldId = expiredException.OldSubscriptionId;
var newId = expiredException.NewSubscriptionId;
Expand All @@ -154,8 +150,8 @@ gcmBroker.OnNotificationFailed += (notification, aggregateEx) => {
// If this value isn't null, our subscription changed and we should update our database
Console.WriteLine ($"Device RegistrationId Changed To: {newId}");
}
} else if (ex is RetryAfterException) {
var retryException = (RetryAfterException)ex;
} else if (ex is RetryAfterException retryException) {

// If you get rate limited, you should stop sending messages until after the RetryAfterUtc date
Console.WriteLine ($"GCM Rate Limited, don't send more until after {retryException.RetryAfterUtc}");
} else {
Expand Down Expand Up @@ -212,8 +208,7 @@ wnsBroker.OnNotificationFailed += (notification, aggregateEx) => {
aggregateEx.Handle (ex => {

// See what kind of exception it was to further diagnose
if (ex is WnsNotificationException) {
var notificationException = (WnsNotificationException)ex;
if (ex is WnsNotificationException notificationException) {
Console.WriteLine ($"WNS Notification Failed: {notificationException.Message}");
} else {
Console.WriteLine ("WNS Notification Failed for some (Unknown Reason)");
Expand Down

0 comments on commit ceb9daf

Please sign in to comment.