2015-01-21 3 views
1

내 소리가 재생되는 동안 내 NSUserNotification이 전달되지만 내 앱이 최상위 애플리케이션이 아닌 경우 시각적으로 화면에 표시되지 않습니다.NSUserNotification이 소리를 내지 만 표시되지 않음

내 응용 프로그램이 백그라운드에있는 경우 알림이 표시되지 않습니다. 내 응용 프로그램이 활성화되어 있으면 표시됩니다. 두 경우 모두 사운드가 재생됩니다.

NSUserNotification *notification = [[NSUserNotification alloc] init]; 
[notification setTitle: @"hi"]; 
[notification setSoundName: NSUserNotificationDefaultSoundName]; 
[notification setDeliveryDate: [NSDate dateWithTimeIntervalSinceNow: 3]]; 
[[NSUserNotificationCenter defaultUserNotificationCenter] scheduleNotification: notification]; 

그리고 나는 항상을 제시 shouldPresentNotification를 오버라이드 (override) 오전 : 여기

내가 통지를 보내고있다 방법이다.

[NSUserNotificationCenter defaultUserNotificationCenter].delegate = self; 

...

- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification { 
    return YES; 
} 

OSX 10.10.1 요세미티

어떻게 항상 소리를 재생하는 것처럼,이 알림은 항상 표시해야합니까?

또는하여 [[NSUserNotificationCenter defaultUserNotificationCenter] removeAllDeliveredNotifications];이 식별자 notification.identifier = @"com.yourcompany.yourapp.notificationidentifier";

에게 변화와 이전의 모든 알림을 제거

답변

0

나는 통지를 만드는 방법은 두 가지가 항상 표시 발견