【发布时间】:2013-02-20 14:58:53
【问题描述】:
我有一个简单的问题。
首先,我将通过发布代码开始:
-(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”导致循环?
我怎样才能显示这些?通知正在指定时间显示,但徽章图标未更改...
谢谢!
-亨利
【问题讨论】:
-
在设置声音和标记图标之后而不是之前安排通知。
-
谢谢! @Lefteris!简单的问题,快速的回复,如果您想回答我会支持并接受的问题。
-
不需要。很高兴有帮助:-)
标签: ios notifications uilocalnotification badge