iphonesdk:如何增加本地通知计数
嗨,我在谷歌日历上工作,当事件开始时,我必须用本地通知保留用户事件 为此,我必须显示通知,如果用户一次有两个事件,则应用程序图标上的本地通知计数必须增加。(如果我一次有两个事件,则计数在应用程序图标上仅显示一个本地通知计数。) 请建议我如何增加应用程序图标上的本地通知计数 请检查我的密码iphonesdk:如何增加本地通知计数,iphone,objective-c,uilocalnotification,Iphone,Objective C,Uilocalnotification,嗨,我在谷歌日历上工作,当事件开始时,我必须用本地通知保留用户事件 为此,我必须显示通知,如果用户一次有两个事件,则应用程序图标上的本地通知计数必须增加。(如果我一次有两个事件,则计数在应用程序图标上仅显示一个本地通知计数。) 请建议我如何增加应用程序图标上的本地通知计数 请检查我的密码 //Local notifications delegates and methods. Class cls = NSClassFromString(@"UILocalNotification"); if (
//Local notifications delegates and methods.
Class cls = NSClassFromString(@"UILocalNotification");
if (cls != nil) {
UILocalNotification *notif = [[cls alloc] init];
notif.fireDate = [[when startTime] date];
notif.timeZone = [NSTimeZone defaultTimeZone];
// Notification details
notif.alertBody = titles;// here title is the key word for the event
// Set the action button
notif.alertAction = nil;
notif.soundName = UILocalNotificationDefaultSoundName;
notif.applicationIconBadgeNumber = 1;
// Specify custom data for the notification
NSDictionary *userDict = [NSDictionary dictionaryWithObject:titles forKey:kRemindMeNotificationDataKey];
notif.userInfo = userDict;
// Schedule the notification
[[UIApplication sharedApplication] scheduleLocalNotification:notif];
[notif release];
}
谢谢假设变量计数包含图标徽章上显示的正确数字,只需执行以下操作:
[UIApplication sharedApplication].applicationIconBadgeNumber = count;
我的答案需要一个数据库: 创建一个按日期和计数排序的数组(数据库)。当通知触发时,调用其计数并使用
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: badgeSortCount]