0
Ich habe Code für Push-Benachrichtigung in ios in C# entwickelt, aber es sendet keine Benachrichtigung in mobilen. Ich habe Pushsharp-Bibliothek verwendet.IOS Push-Benachrichtigung mit Pushsharp in C#
Mein Code ist wie folgt:
PushNotificationApple pushNotification = new PushNotificationApple();
pushNotification.SendNotification(postData);
Mein PushNotificationApple Konstruktorcode ist wie folgt: -
public PushNotificationApple()
{
if (_pushBroker == null)
{
//Create our push services broker
_pushBroker = new PushBroker();
//Wire up the events for all the services that the broker registers
_pushBroker.OnNotificationSent += NotificationSent;
_pushBroker.OnChannelException += ChannelException;
_pushBroker.OnServiceException += ServiceException;
_pushBroker.OnNotificationFailed += NotificationFailed;
_pushBroker.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired;
_pushBroker.OnDeviceSubscriptionChanged += DeviceSubscriptionChanged;
_pushBroker.OnChannelCreated += ChannelCreated;
_pushBroker.OnChannelDestroyed += ChannelDestroyed;
var appleCert = File.ReadAllBytes(System.Web.Hosting.HostingEnvironment.MapPath("~/Certificates" + ConfigSettings.SnaptymAPNSCertificate));
_pushBroker.RegisterAppleService(new ApplePushChannelSettings(false, appleCert,ConfigSettings.SnaptymAPNSPassword)); //Extension method
}
}
Meine SendNotification Funktion ist wie folgt: -
public bool SendNotification(GcmNotificationPostDataModel postData)
{
if (_pushBroker != null)
{
foreach (var registrationId in postData.RegistrationIds)
{
_pushBroker.QueueNotification(new AppleNotification()
.ForDeviceToken(registrationId) //the recipient device id
.WithAlert(postData.Data.Message) //the message
.WithBadge(1)
.WithSound("sound.caf"));
}
}
return true;
}
Welchen Fehler erhalten Sie? Sie können den Prozess in verschiedenen Ereignissen des Push-Brokers verfolgen. Überprüfen Sie, ob es eine Ausnahme gibt – Patel
Stellen Sie sicher, dass dies bei Ihnen nicht der Fall ist http://stackoverflow.com/questions/28499395/apn-production-certificate-not-being-recognized-by-pushsharp – Patel
@patel Guten Ruf für Produktionsumgebung, aber derzeit sendet das OP an Sandbox. Kann im ersten Parameter von 'new ApplePushChannelSettings (false, ....) gesehen werden. 'Und das würde auch eine Ausnahme auslösen. – derpirscher