Facing issue to receive notifications for iOS devices

Hello,

Thank you very much in advance!!

Since yesterday suddenly we are facing an issue to send a notification to iOS devices.
We are using PushSharp.apple v4.0.10 and certification authentication (.p12)

I was debugging the implementation and found that ApnsServiceBroker is not responding after calling a stop() method, Not triggering any of the OnNotificationFailed or OnNotificationSucceeded event, Also not receiving any exception from ApnsServiceBroker instance.

Please find code snippet below,

string certName = AppDomain.CurrentDomain.BaseDirectory + ServiceHelper.GetAppSettingsStringValue("APNSDevCert", string.Empty);

byte[] _applePushNotificationCertificate = File.ReadAllBytes(certName);

ApnsConfiguration config = new ApnsConfiguration(ApnsConfiguration.ApnsServerEnvironment.Sandbox, _applePushNotificationCertificate, "CertPassword");

ApnsServiceBroker apnsBroker = new ApnsServiceBroker(config);

FeedbackService fbs = new FeedbackService(config);

apnsBroker.Start();

apnsBroker.QueueNotification(new ApnsNotification
{
DeviceToken = "DeviceToken",
Code Block
Payload = JObject.Parse("{\"aps\":{\"alert\":\"Test Message\",\"badge\":0,\"content-available\":1,\"sound\":\"default\"}}")
});

apnsBroker.OnNotificationFailed += (notification, aggregateEx) =>
{
aggregateEx.Handle(ex =>
{
// See what kind of exception it was to further diagnose
if (ex is ApnsNotificationException)
{
ApnsNotificationException notificationException = (ApnsNotificationException)ex;

// Deal with the failed notification
var apnsNotification = notificationException.Notification;
var statusCode = notificationException.ErrorStatusCode;

log.Error($"Apple Notification Failed: ID={apnsNotification.Identifier}, Code={statusCode}" + "Message=" + ex.Message + "stckstrace=" + ex.StackTrace);
}
else
{
// Inner exception might hold more useful information like an ApnsConnectionException
log.Error($"Apple Notification Failed for some unknown reason : {ex.InnerException}" + "Message=" + ex.Message + "stckstrace=" + ex.StackTrace);
}

return true;
});

};


apnsBroker.OnNotificationSucceeded += (notification) =>
{
log.Info($"Apple Notification Sent for ID={notification.DeviceToken}");
};

fbs.FeedbackReceived += (string deviceTokenLocal, DateTime timestamp) =>
{
log.Info($"Apple Notification Sent for ID={deviceTokenLocal}");
};
Code Block
apnsBroker.Stop();

I am not getting any exception, any error, any success or any feedback response after calling apnsBroker.Stop() method. Till yesterday it was perfectly working.

Did any one faced the same kind of issue.


I think this issue is related to this topic https://developer.apple.com/news/?id=c88acm2b,

so I suggest you to update APNs provider API, like it is described here
Code Block
https://gobiko.com/blog/token-based-authentication-http2-example-apns/

Yes, if you are still using the old binary interface which is now retired (since March 31st, 2021) that would explain why you are no longer able to send push notifications.

This requires you to migrate your push servers to use the HTTP/2 API. Any push servers still using the legacy interface will be unable to connect to APNs, resulting in Push Notifications not working. 

More information about the HTTP/2 provider API can be found in these two WWDC sessions:

WWDC2015 Whats New in Notifications <https://developer.apple.com/videos/play/wwdc2015/720/>
WWDC2016 Whats New in the Apple Push Notification Service <https://developer.apple.com/videos/play/wwdc2016/724/>

You can read more about the new APNs Provider API here:
https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns/

Facing issue to receive notifications for iOS devices
 
 
Q