我有一个简单的问题。
首先,我将从发布代码开始:
-(void)notification
{
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
if (!localNotification)
return;
// Current date
NSCalendar *calendar = [NSCalendar currentCalendar]; // gets default calendar
NSDateComponents *components = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit) fromDate:[NSDate date]]; // gets the year, month, day, hour and minutesfor today's date
[components setHour:19];
[components setMinute:30];
[components setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"EST"]];
localNotification.fireDate = [calendar dateFromComponents:components];
localNotification.repeatInterval = NSDayCalendarUnit;
[localNotification setAlertBody:@"Your 'Daily Quote' is ready!"];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
localNotification.applicationIconBadgeNumber = 1;
localNotification.soundName = UILocalNotificationDefaultSoundName;
}
似乎显示了 localNotification,但从未显示和播放徽章和声音。可能是因为这是由于“repeatInterval”而循环的吗?
我怎样才能让这些显示出来?通知正在指定时间显示,但徽章图标未更改...
谢谢!
-亨利