J'utilise le dernier PushSharp (4.0.10) pour envoyer des notifications aux appareils iOS et Android. Il y a environ 9 mois, j'ai testé cela et cela semblait fonctionner correctement. J'ai essayé la même application aujourd'hui et l'appareil (iPhone) ne reçoit plus les notifications. Le jeton d'appareil a été mis à jour aujourd'hui, il devrait donc être valide. L'événement apnsBroker.OnNotificationSucceeded est renvoyé mais l'appareil ne reçoit jamais la notification. Il n'y a aucune exception ou tout autre type de commentaires.PushSharp envoi de notifications à iOS réussi mais pas reçu
var config = new ApnsConfiguration(ApnsConfiguration.ApnsServerEnvironment.Sandbox, "mycert.p12", "password");
// 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)
{
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();
var payload = new Dictionary<string, object>();
var aps = new Dictionary<string, object>();
aps.Add("alert", GetAlert());
aps.Add("badge", 1);
aps.Add("sound", "chime.aiff");
payload.Add("aps", aps);
payload.Add("data", "info");
apnsBroker.QueueNotification(new ApnsNotification
{
DeviceToken = textBox1.Text,
Payload = JObject.Parse(Newtonsoft.Json.JsonConvert.SerializeObject(payload))
});
apnsBroker.Stop();
mettez-vous à jour le jeton vers votre serveur lorsque vous recevez un nouveau jeton d'APN? Sinon, mettez-vous en cache le jeton une fois que vous l'avez obtenu? – Subramanian
Je mets toujours le jeton à jour pour m'assurer qu'il n'a pas expiré. – jbassking10
Pouvez-vous passé le code de jeton recevoir? – Subramanian