在通知中心配置所有内容(允许应用程序显示通知)后,我的应用程序的本地通知不会触发.
你遇到同样的问题吗?
更多信息:
几天前用相同的源代码编译的同一个应用程序,使用XCode 4.1和iOS 4.3 SDK编译,一切运行良好.
此外,使用旧版XCode和iOS SDK编译的应用程序可以在升级后在iOS5上运行.
但是,使用相同代码编译的应用程序,但XCode 4.2和iOS5 SDK不起作用.
你有什么想法?或者iOS5有什么特别的工作吗?
示例代码如下:
UIApplication *app = [UIApplication sharedApplication];
NSArray *oldNotifications = [app scheduledLocalNotifications];
// Clear out the old notification before scheduling a new one.
if (0 < [oldNotifications count]) {
[app cancelAllLocalNotifications];
}
// Create a new notification
UILocalNotification *alarm = [[UILocalNotification alloc] init];
if (alarm) {
alarm.fireDate = theDate;
alarm.timeZone = [NSTimeZone defaultTimeZone];
alarm.repeatInterval = NSDayCalendarUnit; //repeat every day
alarm.alertBody = [NSString stringWithFormat:@"alert"];
[app scheduleLocalNotification:alarm];
[alarm release];
} …Run Code Online (Sandbox Code Playgroud)