2012-06-15 3 views
1

저는 UILocalNotification에 대한 API를 살펴 보았습니다. 나는 firedate가 부딪 칠 때 배지 번호 만 정하고 싶다. 팝업이 없습니다. 배지 번호가 1이고 알림 본문이 없기 때문에 알림을 설정하려고했습니다. 그러나이 didnt 한 일.UILocalNotifications는 배지 만 표시합니다.

//Add new local push notification 
locationNotification.fireDate = date; 
locationNotification.timeZone = [NSTimeZone defaultTimeZone]; 
//locationNotification.alertBody = [NSString stringWithFormat:body]; 
//locationNotification.alertAction = @"Ok"; 
//locationNotification.soundName = UILocalNotificationDefaultSoundName; 
locationNotification.applicationIconBadgeNumber = 1; 

이것이 가능합니까? 일단 앱을 열면 메시지 만 표시하려고합니다.

답변

1

내가 작업 한 프로젝트에서 이와 비슷한 것을 성취했습니다. 경고없이 배지 번호 만 표시해야했습니다. 알림에 '소리'를 추가해야 할 수도 있습니다. 내가 수행 한 작업은 0.5 두 번째 자동 사운드 파일을 추가하는 것입니다. 내 코드는 다음과 같습니다.

 UILocalNotification *notif = [[UILocalNotification alloc] init]; 
     notif.fireDate = [NSDate date]; 
     notif.timeZone = [NSTimeZone defaultTimeZone]; 
     notif.soundName = @"silence.caf"; 
     notif.applicationIconBadgeNumber = 2; 
     [[UIApplication sharedApplication] scheduleLocalNotification:notif]; 
     [notif release]; 

희망이 있습니다.

+0

답장 skram을 주셔서 감사합니다, 유일한 것은 내 코드에서 누락 된 것 같습니다 사운드 이름입니다. 나는 UILocalNotificationDefaultSoundName으로 남겨 뒀다. 그러나이 didnt는 차이를 만드는 것처럼 보인다. – user987723

+0

또한,'fireDate'의 예상 시간이 유효하다는 것을 다시 한번 확인한다. 그렇지 않으면 실제로 일어나지 않는 것을 기대할 수 있습니다. – skram

+0

내가 경고 바디를 주석 처리하고 작동하는 경우 조치가 정상이면. 그래서 fireDate는 괜찮아요. – user987723

0

이 질문은 오래된 질문이지만, 이는 도움이되기를 바랍니다. 나는 조용한 지역 통보를 전혀 계획 할 수 없다고 생각했지만, 그것은 그렇다고 볼 수 있습니다.

이 작동 : 내가 예약 통지에이 알림을 확인할 수 있도록

UILocalNotification* notification = [[UILocalNotification alloc] init]; 
    notification.fireDate = [NSDate dateWithTimeIntervalSinceNow:10]; 
    notification.timeZone = [NSTimeZone systemTimeZone]; 
    notification.alertBody = nil;   
    notification.applicationIconBadgeNumber = 99; 
    [[UIApplication sharedApplication] scheduleLocalNotification:notification]; 

가 나는 또한 그러나이 해고되는 것을 통지를 방지하기 위해 듯, 사용자 정보 속성에 몇 가지 정보를 추가했습니다.

대신에 soundName 속성으로 소리없는 파일을 사용하고 있으므로 테스트 할 수 있습니다. 그러나 소리없는 오디오 파일은 실제로 알림을 실행하는 데 필요하지는 않습니다.

배지를 예약 할 때 알 수있는 값으로 업데이트하는 것보다 유용한 기능을 원한다면 자동 푸시 알림을 사용하고 "content-available"플래그를 설정해야합니다.

관련 문제