我正在开发包含本地通知的新项目(这不是我第一次使用此功能)。
如果每次启动特定的UIViewController时都会检查本地通知。
我的问题在于:在第一次检查中,notifications数组包含通知,但在第二次检查中,notifications数组变为空。
这里是我注册通知的代码
localNotif.fireDate = newDate;
localNotif.timeZone = [NSTimeZone defaultTimeZone];
localNotif.alertBody =[NSString stringWithFormat: @"SomeTEXT"];
localNotif.alertAction = @"SomeTEXT";
localNotif.repeatInterval=NSWeekCalendarUnit;
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 1;
NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"jomaa" forKey:@"Key"];
localNotif.userInfo = infoDict;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
这也是通知数组的输出(当数组不为空时)
打印notificationArray的说明:
<__NSArrayM 0x1d2bb4e0>( <UIConcreteLocalNotification:
0x1d2baf10>{fire date = Friday, January 18, 2013, 3:24:00 PM Eastern
European Standard Time, time zone = Asia/Beirut (GMT+02:00) offset
7200, repeat interval = NSWeekCalendarUnit, repeat count =
UILocalNotificationInfiniteRepeatCount, next fire date = Friday,
January 18, 2013, 3:24:00 PM Eastern European Standard Time, user info
= {
Key = jomaa;
}
}
)