与APNS尖锐苹果推送通知 [英] apple push notification with APNS sharp
问题描述
我使用APNS夏普库我的苹果推送通知。我已经从提供这里。我使用的样本测试程序downloded通过没有任何修饰APNS尖锐库。
结果它只是直到我把在该行code的突破点不发出任何通知。
如果我把突破点。我刚工作fine.is此预期的行为还是我做错了什么。而且我没有得到任何异常。感谢您的帮助。
这里是code
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();
}
我希望我的问题是清楚的...结果
更新:我坚持here.please任何一个可以帮助我
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屋!