带有 APNS 锐利的苹果推送通知 [英] apple push notification with APNS sharp
问题描述
我将 APNS Sharp 库用于我的苹果推送通知.我从这里下载.我使用APNS提供的示例测试程序锐利的库没有任何修改.
在我在该行代码处放置断点之前,它根本不会发送任何通知.如果我放断点.我只是工作正常.这是预期的行为还是我做错了什么.而且我也没有得到任何例外.谢谢你的帮助.这是代码
i use APNS Sharp library for my apple push notification. i have downloded from Here.i use sample test program provided by APNS sharp library without any modification.
it simply does not send any notification until i put break point at that line of code.
if i put break point. i just work fine.is this expected behaviour or i am doing something wrong. and also i am not getting any exception. thanks for any help.
here is the code
static void Main(string[] args)
{
bool sandbox = true;
string testDeviceToken = "Token";
string p12File = "apn_developer_identity.p12";
string p12FilePassword = "yourpassword";
int sleepBetweenNotifications = 15000;
string p12Filename = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, p12File);
NotificationService service = new NotificationService(sandbox, p12Filename, p12FilePassword, 1);
service.SendRetries = 5;
service.ReconnectDelay = 5000; //5 seconds
service.Error += new NotificationService.OnError(service_Error);
service.NotificationTooLong += new NotificationService.OnNotificationTooLong(service_NotificationTooLong);
service.BadDeviceToken += new NotificationService.OnBadDeviceToken(service_BadDeviceToken);
service.NotificationFailed += new NotificationService.OnNotificationFailed(service_NotificationFailed);
service.NotificationSuccess += new NotificationService.OnNotificationSuccess(service_NotificationSuccess);
service.Connecting += new NotificationService.OnConnecting(service_Connecting);
service.Connected += new NotificationService.OnConnected(service_Connected);
service.Disconnected += new NotificationService.OnDisconnected(service_Disconnected);
Notification alertNotification = new Notification(testDeviceToken);
alertNotification.Payload.Alert.Body = "Testing {0}...";
alertNotification.Payload.Sound = "default";
alertNotification.Payload.Badge = i;
if (service.QueueNotification(alertNotification))
Console.WriteLine("Notification Queued!");
else
Console.WriteLine("Notification Failed to be Queued!");
Console.WriteLine("Cleaning Up...");
service.Close();// if i dont put a break point in here, it simply does not send any notification
service.Dispose();
}
我希望我的问题很清楚...
更新:我被困在这里.请任何人可以帮助我.
i hope my question is clear...
Update: i am stuck here.please any one can help me.
推荐答案
我发现了问题.这是 APNS SHARP 库线程工作流中的错误.
i found out the problem. it was error in APNS SHARP library thread workflow.
我在排队所有通知后调用此方法.
喜欢
service.start();
这是方法
i am calling this method after queueing all the notification.
like
service.start();
and here is method
public void Send()
{
foreach (NotificationConnection conn in this.notificationConnections)
{
// Console.Write("Start Sending");
conn.start(P12File, P12FilePassword);
}
}
这篇关于带有 APNS 锐利的苹果推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!