PushSharp 3.0 Info: https://github.com/Redth/PushSharp/tree/3.0-dev#pushsharp-v30---the-push-awakens
dependabot[bot] on nuget
Bump Newtonsoft.Json from 7.0.1… (compare)
dependabot[bot] on nuget
Bump Newtonsoft.Json from 7.0.1… (compare)
running = false;
notifications.CompleteAdding();
lock( lockWorkers )
{
// Kill all workers right away
if( immediately )
workers.ForEach( sw => sw.Cancel() );
var all = ( from sw in workers
select sw.WorkerTask ).ToArray();
Log.Info( "Stopping: Waiting on Tasks" );
Task.WaitAll( all, millisecondsTimeout );
Log.Info( "Stopping: Done Waiting on Tasks" );
workers.Clear();
}
}
var apnsBroker = new ApnsServiceBroker(config);
// Wire up events
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;
// Deal with the failed notification
var apnsNotification = notificationException.Notification;
var statusCode = notificationException.ErrorStatusCode;
Console.WriteLine($"Apple Notification Failed: ID={apnsNotification.Identifier}, Code={statusCode}");
}
else
{
// Inner exception might hold more useful information like an ApnsConnectionException
Console.WriteLine($"Apple Notification Failed for some unknown reason : {ex.InnerException}");
}
// Mark it as handled
return true;
});
};
apnsBroker.OnNotificationSucceeded += (notification) => {
Console.WriteLine("Apple Notification Sent!");
};
// Start the broker
apnsBroker.Start();
// Queue a notification to send
apnsBroker.QueueNotification(new ApnsNotification
{
DeviceToken = "c25b43afacd7ed3d496eca80b89c9f248983e5d0ec385b3b6237f0cbbd0b4e51",
Payload = JObject.Parse("{\"aps\":{\"badge\":7}}")
});
// Stop the broker, wait for it to finish
// This isn't done after every message, but after you're
// done with the broker
apnsBroker.Stop();