2012-12-28 2 views
1

이것은 내가 가지고있는 코드이며 응용 프로그램 배지에 날짜를 넣습니다. 나는이 번호를 다시로드하는 애플 리케이션을 입력하지 않고 매일이 번호를 다시로드하는 방법을 궁금 해서요. 미리 감사드립니다!하루에 한 번 응용 프로그램 배지 업데이트

NSDate *today = [NSDate date]; 
NSCalendar *cal = [NSCalendar currentCalendar]; 
NSDateComponents *comp = [cal components:NSDayCalendarUnit fromDate:today]; 
NSInteger day = [comp day]; 
[UIApplication sharedApplication].applicationIconBadgeNumber = day; 
+0

알림을 푸시 할 수 있습니다 ... –

+0

예 - 푸시 알림 - 여기에 관련 게시물이 있습니다. http://stackoverflow.com/questions/11153631/increment-the-push-notification-badge-iphone – bryanmac

답변

1

배경에 배지를 설정하는 코드를 삽입하는 것이 상대적으로 쉬운 방법입니다. 이 목적으로 [UIApplication beginBackgroundTaskWithExpirationHandler] 또는 관련 전화를 사용할 수 있습니다. 유일한 문제는 그러한 실행에 대해 10 분 제한이 있다는 것입니다. 그런 한계를 피하기 위해 사용할 수있는 트릭이 있습니다. Run app for more than 10 minutes in background

0

것은 내가 코드를 다음과 같습니다 :

NSDate *fireTime = [[NSDate date] addTimeInterval:3600*24]; 
notification.fireDate = fireTime; 
notification.alertBody = @"Your Message!"; 
notification.applicationIconBadgeNumber = 1; 
[[UIApplication sharedApplication] scheduleLocalNotification:notification]; 

당신이 시뮬레이터에서 테스트하는 경우 다음 아마 당신은 출력을 얻지 못하고 있습니다 이유입니다 다음은이 주제에 대해 설명 훌륭한 스레드입니다. 장치에서 테스트하고 작동하는지 확인하십시오.

관련 문제