2013-03-02 2 views
0
다음
UILocalNotification *localNotification = [[UILocalNotification alloc] init]; 
[localNotification setFireDate:[NSDate dateWithTimeIntervalSinceNow:3600]]; 
[localNotification setAlertAction:@"Launch"]; 
[localNotification setAlertBody:[alertBodyField text]]; 
[localNotification setHasAction: YES]; 
[localNotification setApplicationIconBadgeNumber:[[UIApplication sharedApplication] applicationIconBadgeNumber]+1]; 
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; 
[alertNotification setHidden:NO]; 

답변

0

목록 :

는 하루 달에 역법 단위를 지정합니다. 귀하의 경우에는

enum { 
    NSEraCalendarUnit = kCFCalendarUnitEra, 
    NSYearCalendarUnit = kCFCalendarUnitYear, 
    NSMonthCalendarUnit = kCFCalendarUnitMonth, 
    NSDayCalendarUnit = kCFCalendarUnitDay, 
    NSHourCalendarUnit = kCFCalendarUnitHour, 
    NSMinuteCalendarUnit = kCFCalendarUnitMinute, 
    NSSecondCalendarUnit = kCFCalendarUnitSecond, 
    NSWeekCalendarUnit = kCFCalendarUnitWeek, 
    NSWeekdayCalendarUnit = kCFCalendarUnitWeekday, 
    NSWeekdayOrdinalCalendarUnit = kCFCalendarUnitWeekdayOrdinal, 
    NSQuarterCalendarUnit = kCFCalendarUnitQuarter, 
    NSWeekOfMonthCalendarUnit = kCFCalendarUnitWeekOfMonth, 
    NSWeekOfYearCalendarUnit = kCFCalendarUnitWeekOfYear, 
    NSYearForWeekOfYearCalendarUnit = kCFCalendarUnitYearForWeekOfYear 
    NSCalendarCalendarUnit = (1 << 20), 
    NSTimeZoneCalendarUnit = (1 << 21), 
}; 
typedef NSUInteger NSCalendarUnit; 

:

'NSWeekCalendarUnit'에 반복 간격을 설정하면 트릭을해야한다. 원래 통지와 동일한 요일과 시간에 매주 반복됩니다.

알림의 설정 사운드를

: 사용자 정의 사운드

localNotification.soundName = @"alarm_sound.wav";// put name of sound file 
0
UILocalNotification *localNotification = [[UILocalNotification alloc] init]; 
[localNotification setFireDate:[NSDate dateWithTimeIntervalSinceNow:3600]]; 
[localNotification setAlertAction:@"Launch"]; 
[localNotification setAlertBody:[alertBodyField text]]; 
[localNotification setHasAction: YES]; 

// change 
localNotification.repeatInterval = NSWeekCalendarUnit; // set the repeat interval 
localNotification.soundName = UILocalNotificationDefaultSoundName; // set alert sound 

[localNotification setApplicationIconBadgeNumber:[[UIApplication sharedApplication] applicationIconBadgeNumber]+1]; 
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; 
[alertNotification setHidden:NO]; 
를 들어

localNotification.soundName = UILocalNotificationDefaultSoundName; // Here you can also use custom sound . 

관련 문제