Reputation: 83
I'm using PushSharp 4.0.10 In the OnNotificationFailed event of the Apns broker, I get "The function requested is not supported" exception. There is my Broker creator
private static ApnsServiceBroker CreateApnsBroker(string certificate)
{
// Configuration (NOTE: .pfx can also be used here)
var config = newApnsConfiguration(
ApnsConfiguration.ApnsServerEnvironment.Sandbox,
certificate,
ConfigurationManager.AppSettings["Cert_Passwd"],
false);
// Create a new broker
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 notificationException)
{
// Deal with the failed notification
var apnsNotification = notificationException.Notification;
var statusCode = notificationException.ErrorStatusCode;
Logger.Info($"Apple Notification Failed:
ID={apnsNotification.Identifier},
Code={statusCode}",
ex);
}
else
{
// Inner exception might hold more useful information
// like an ApnsConnectionException
Logger.Info($"Apple Notification Failed for some unknown reason:
{ex.InnerException}",
ex);
}
// Mark it as handled
return true;
});
};
apnsBroker.OnNotificationSucceeded += (notification) =>
{
Logger.Info($"Apple Notification Sent for device {notification.DeviceToken}");
};
return apnsBroker;
}
Send notification
private static void QueueNotification(
ApnsServiceBroker apnsBroker,
string deviceToken,
string payload)
{
// Queue a notification to send
apnsBroker.QueueNotification(new ApnsNotification
{
DeviceToken = deviceToken,
Payload = JObject.Parse(payload),
Expiration = DateTime.Now.AddDays(2)
});
}
When I stop the broker in OnNotificationFailed catch exception. In PushSharp and in my code I using ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 Using .p12 certificate for voip notifications, it's added in mmc What's my mistake?
Upvotes: 4
Views: 1293
Reputation: 7228
Temporary fix:
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
Put this in your application_startup or startup.cs
Upvotes: 0
Reputation: 423
It seems that the package in Nuget is not up to date with the code in Github. The latest version in Github supports TLS 1.2, which recently became mandatory. Therefore, the only solution is to clone the repo, build it yourself and add a reference to the newly built DLL.
Upvotes: 0
Reputation: 83
I clone PushSharp repo, compile local dll, change project links and it's work, but I don't know why.
Upvotes: 1