1
큰 문제가 있습니다! 내 문제는 구현 된 내 대리자 localnotification 코드입니다. didEnterBackround 메서드에이 코드를 추가했습니다. 그러나, 각 didEnterBackround에 대한 localnotifi를 얻습니다. 최신 정보가 사라진 경우에만 새로운 알림 만 실행되도록 할 수 있습니까? 만약 내가 5 일 후에 발사하는 localnotifi를 가지고있는 것처럼. 내가 열 다섯 번 응용 프로그램을 닫고 5 일 기다릴 때 나는 5 localnotifications를 얻을. 앱이 단지 하나의 소동을 일으킬 수있게 할 수 있습니까? 그러면 새로운 앱이 시작되면 나타나는 것입니까?!한 번만 로컬 알림을 표시하십시오
내 코드 : 당신은 모든 예약 통지 취소 할 수있어
NSCalendar *calender = [NSCalendar autoupdatingCurrentCalendar];
NSDate *currentDate = [NSDate date];
NSDateComponents *dateComponents = [calender components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:currentDate];
NSDateComponents *timeComponents = [calender components:(NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit) fromDate:currentDate];
NSDateComponents *temp = [[NSDateComponents alloc]init];
[temp setYear:[dateComponents year]];
[temp setMonth:[dateComponents month]];
[temp setDay:[dateComponents day]];
[temp setHour:[timeComponents hour]];
[temp setMinute:[timeComponents minute]];
[temp setSecond:[timeComponents second] +10];
NSDate *fireTime = [calender dateFromComponents:temp];
UILocalNotification *localN = [[UILocalNotification alloc]init];
localN.fireDate = fireTime;
localN.timeZone = [NSTimeZone defaultTimeZone];
localN.alertBody = @"BLA BLA BLA!";
localN.alertAction = @"GO BACK";
localN.applicationIconBadgeNumber = 1;
[[UIApplication sharedApplication] scheduleLocalNotification:localN];
나를 위해 코드 스 니펫을 만들 수 있습니까? 나는 당신이 실제로 무엇을 의미하는지 또는이 코드를 어디에 넣어야 하는지를 정말로 이해하지 못한다. 미안 해요, 내가 초보자이기 때문에 – MasterRazer
'[[UIApplication sharedApplication] cancelAllLocalNotifications];'를 당신이 우리에게 준 코드 위에 놓으십시오. (NSCalendar 행 위). 그것은 당신이 원하는대로 작동합니다. –
빠른 응답에 감사드립니다. 그렇게 할게요 – MasterRazer