我使用APNS Sharp庫進行蘋果推送通知。我從Here下滑。我使用APNS銳庫提供的樣本測試程序,沒有任何修改。
它只是不發送任何通知,直到我把斷點放在該行的代碼。 如果我把斷點。我只是工作fine.is這種預期的行爲,或者我做錯了什麼。而且我也沒有得到任何例外。謝謝你的幫助。 這裏是代碼APNS尖銳的蘋果推送通知
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任何一個能幫助我。
只是檢查:你有你的證書,對吧?你的密碼是「yourpassword」嗎?只是想知道這是從這個例子中遺留下來的東西。 – ACBurk 2010-07-06 23:21:30
謝謝ACBurk。是的,我擁有一切。如果我放置斷點,它就可以正常工作。 – Nnp 2010-07-06 23:24:38