2015-01-01 1 views
0

iTunes 및 Spotify가 게시하는 모든 배포 알림 목록이 필요합니다. 나는 SO 또는 Google에서 그러한 것을 찾을 수없는 것 같아서 모든 알림을 구독하고 어떤 알림이 트리거되는지 메모하고 싶었습니다. 성공적으로 구독했으나 모두 구독 할 수 없습니다.배포 된 모든 응용 프로그램 알림 신청 (또는 나열)

// Works just fine 
NSDistributedNotificationCenter *center = [NSDistributedNotificationCenter defaultCenter]; 
[center addObserver:self selector:@selector(itunesNotification) 
       name:@"com.apple.iTunes.playerInfo" object:nil]; 
[center addObserver:self selector:@selector(spotifyNotification) 
       name:@"com.spotify.client.PlaybackStateChanged" object:nil]; 

// Doesn't work :(
[center addObserver:self selector:@selector(itunesNotification) 
       name:@"com.apple.iTunes" object:nil]; 
[center addObserver:self selector:@selector(itunesNotification) 
       name:@"com.apple.iTunes.*" object:nil]; 
// Same result with com.spotify.client and .* 

다시 말해서 모든 iTunes/Spotify 알림 목록을 사용할 수 있다면 다시 작동합니다. 내 의도는 결국 모든 알림을 구독하는 것이 아니라 그곳에 무엇이 있는지보고 몇 가지를 선택하는 것입니다. 이해가 되길 바래, 고마워.

답변

2

나는 그것을 알아 냈다! nil을 이름으로 제공하여 Mac에서 모든 분산 알림을 볼 수 있습니다.

NSDistributedNotificationCenter *center = [NSDistributedNotificationCenter defaultCenter]; 
[center addObserver:self selector:@selector(allNotifications:) name:nil object:nil]; 
+1

"NSDistributedNotificationCenter"시스템에서 "모든 응용 프로그램 알림"은 아니지만 ** 모든 ** 알림은 사용하지 않도록주의하십시오. 얼마나 많은 응용 프로그램이 실행되고 있고 사용 중인지에 따라 ** 많은 양의 알림을 받게됩니다. '-noNotifications'에서 그것들을'if' 문에서 통지의'userInfo' dict를 사용하여 걸러 낼 필요가 있습니다. –

+0

맞습니다. 감사! @ 줄리안 – vqdave