当我记录本地通知的描述
时`<UIConcreteLocalNotification: 0x1edd4d40>{fire date = Thursday, September 26, 2013, 11:15:00 AM India Standard Time, time zone = Asia/Kolkata (GMT+05:30) offset 19800, repeat interval = 0, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = Thursday, September 26, 2013, 11:15:00 AM India Standard Time, user info = {
UID = "38BF41F8-05D3-48E2-A20F-7B84609F4E85";
}}`
我发现了“重复计数”参数。是否有任何选项可以设置重复计数,使其重复此计数和已过期
答案 0 :(得分:0)
在这个问题中提出了一个可行的解决方法。 Cancelling single occurence of repeating local notification
但是,这表明我不认为可以通过重复计数来区分重复的本地通知。
答案 1 :(得分:0)
您无法为此目的设置任何重复计数。但是,您可以在收到通知后通过必要的检查修改fireDate,然后再次安排它。
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
localNotif = notification;
int no_of_days = [self getNumberOfDaysToNextAlarmInDays];
int day = 24*60*60;
NSTimeInterval interval = day *no_of_days;
localNotif.fireDate = [NSDate dateWithTimeInterval:interval sinceDate:[NSDate date]];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
}
-(int)getNumberOfDaysToNextAlarmInDays {
//do the necessary calculations here
return count ;
}
这里的一个小问题是它仅在调用 didReceiveLocalNotification 时有效。
答案 2 :(得分:0)
您可以将重复计数作为数字。在调用Appdelegate
didReceiveLocalNotification
方法中的通知时。在该方法中,您可以获得重复计数。在那里,您可以减少重复次数并重新安排通知。如果重复计数为0,则无需重新安排notification
。
例如:
if ([[notification.userInfo objectForKey:@"repeat"]intValue] != 0) {
//You can again schedule your notification here with decrementing the repeat count.
}else{
}
//Here you can cancel the current notification
[[UIApplication sharedApplication]cancelLocalNotification:notification];
希望这会有所帮助:)