Привет, у меня проблемы с моим приложением, где я хочу добавить некоторые базовые LocalNotifications, которые повторяются каждую неделю. Я хочу сделать это в методе «schedLocalNotificationForItem:», который вызывается при нажатии кнопки doneBarButtonItem. Кажется, что все это работает до сих пор, потому что когда я регистрирую все запланированные уведомления, появляется каждое запланированное уведомление. Но когда я использую это приложение, запланированные уведомления запускаются и отображаются, но есть некоторые дополнительные уведомления, которые я не задал себе, и я не могу определить, откуда они происходят, которые тоже появляются.UILocalNotification запускается, но не назначается
Так вот мой код:
- (int)scheduleNotifitactionsForItem:(AlarmItem *)item
{
NSArray *reorderdRepeat = [NSArray arrayWithArray:[self transformArray:item.repeat]];
int missedDays = 0;
int scheduledAlarms = 0;
for (int i = 0; i < item.repeat.count; i++) {
if ([[reorderdRepeat objectAtIndex:i] boolValue] == true) {//Problem determinating true values at end of array
NSInteger integerOfDay = i + 1;//reorderRepeat should contain seven items, icrement i bevore adding it to integerOfDay
NSDate *lastAlarmTime = [self getFireDateForDayOfWeek:integerOfDay withTime:item.time];
NSArray *allAlramTimesForDay = [self getFireDatesForTime:lastAlarmTime andCycle:item.cycles];
for (int i = 0; i < allAlramTimesForDay.count; i++) {
NSDate *alarmTime = [allAlramTimesForDay objectAtIndex:i];
UIApplication *application = [UIApplication sharedApplication];
UILocalNotification *notification = [UILocalNotification new];
NSDictionary *userInfo = @{@"index":[NSString stringWithFormat:@"%d",item.notification]};
notification.repeatInterval = NSCalendarUnitWeekday;
notification.alertBody = item.title;
notification.userInfo = userInfo;
notification.fireDate = alarmTime;
notification.soundName = item.sound;
[application scheduleLocalNotification:notification];
scheduledAlarms += 1;
}
} else {
missedDays += 1;
}
}
return scheduledAlarms;
}
Помощь ценится;)
Могут быть другие уведомления из других приложений, установленных на вашем устройстве, а не из одного приложения, или вы получаете уведомление от того же приложения? – iphonic