嗨,我正在使用 Google 日历,当活动开始时,我必须在本地通知中保留用户活动。
为此我必须显示通知,如果用户一次有两个事件,则本地通知计数必须在应用程序图标上增加。(如果我一次有两个事件,计数也只在应用程序图标上显示一个本地通知计数) .
请建议我如何增加应用程序图标上的本地通知计数。
请检查我的代码。
//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];
}
谢谢