Created
February 28, 2017 18:52
-
-
Save karnlund/569bf915aefc24597129d64ed2a20a6a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
| #if defined( DEBUG ) | |
| [self dumpNotifications]; | |
| #endif | |
| return YES; | |
| } | |
| - (void)dumpNotifications { | |
| #define Debugger() { kill( getpid(), SIGINT ) ; } | |
| NSNotificationCenter *notifyCenter = [NSNotificationCenter defaultCenter]; | |
| NSArray *ignoreList = @[@"_", | |
| // ??? | |
| @"com.apple.pasteboard", | |
| @"AXFrontBoard", | |
| @"FABSettingsAvailableNotification", | |
| @"kGTMSession", | |
| // UIKit | |
| @"NSBundle", | |
| @"UIApplication", | |
| @"UIDevice", | |
| @"UIWindow", | |
| @"UIView", | |
| @"UIText", | |
| @"UIStatusBar", | |
| @"UIKeyboard", | |
| @"UINavigationController", | |
| // user defaults | |
| @"NSUserDefaults", | |
| // rendering? | |
| @"BufferBacking", | |
| @"PBDefault", | |
| @"com.urbanairship", | |
| @"CTRadioAccess", | |
| // core data | |
| @"NSPersistentStore", | |
| @"NSObjectsChangedInManagingContextNotification", | |
| @"NSManagingContext", | |
| @"NSManagedObject", | |
| @"NSSQL", | |
| // Flurry? | |
| @"FIRAScreen", | |
| @"Flurry", | |
| // GCD | |
| @"NSThread"]; | |
| [notifyCenter addObserverForName:nil | |
| object:nil | |
| queue:nil | |
| usingBlock:^(NSNotification *notification){ | |
| NSString *name = [notification name]; | |
| for (NSString *item in ignoreList) { | |
| if ([name hasPrefix:item]) { | |
| return; | |
| } | |
| } | |
| // if ([name isEqualToString:@"NSThreadWillExitNotification"]) { | |
| // Debugger() | |
| // } | |
| // Explore notification | |
| NSLog(@"Notification found with:" | |
| "\r\n name: %@" | |
| "\r\n object: %@" | |
| "\r\n userInfo: %@", | |
| [notification name], | |
| [notification object], | |
| [notification userInfo]); | |
| }]; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Learn what notifications your app is really seeing by dumping all of them to the console!
This code has a configurable ignore list that you can easily customize to see as little or as much as you want. I'm certain you will learn about notifications that you never even knew existed to make better apps, like UIScreenBrightnessDidChangeNotification.