我最近做了一個包含本地通知的客戶端應用程序。在原始版本中,通知工作得很好。但是,當客戶端試圖發佈另一個版本時,只更改了圖像和數據庫資源,代碼中沒有任何更改,通知就停止工作。現在我一直在試圖調試代碼,但一無所獲。一切似乎都很好,但沒有通知。同時,如果我運行較早的版本,它的工作完美。你能幫我解決什麼可能是錯的嗎?非常感謝你花時間陪伴。本地通知停止出現?
NSTimeInterval diffTimeIntervalSinceNow = timeInterval; //time-interval after which notification should appear
UILocalNotification *localNotification = [[UILocalNotification alloc] init]; //Create the localNotification object
[localNotification setFireDate:[NSDate dateWithTimeIntervalSinceNow:diffTimeIntervalSinceNow]]; //Set the date when the alert will be launched using the date adding the time the user selected on the timer
//[localNotification setRepeatInterval:notificationInterval];
[localNotification setAlertAction:@"Launch"]; //The button's text that launches the application and is shown in the alert
[localNotification setAlertBody:alertBody]; //Set the message in the notification from the textField's text
[localNotification setHasAction: YES]; //Set that pushing the button will launch the application
[localNotification setApplicationIconBadgeNumber:[[UIApplication sharedApplication] applicationIconBadgeNumber]+1]; //Set the Application Icon Badge Number of the application's icon to the current Application Icon Badge Number plus 1
[[UIApplication sharedApplication] cancelAllLocalNotifications];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; //Schedule the notification with the system
[localNotification release];
這就是我一直在使用的代碼。但是,這是在早期版本中工作的完全相同的代碼。
沒有什麼變化。我猜代碼是好的因爲我把兩個類與'fileMerge'進行了比較,並且沒有任何區別。 – Ahmed