Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
src
 
 
 
 

FPCrashHandler

FPCustomHandler is a helper class for Crashlytics to allow you run custom NSUncaughtExceptionHandler or signal handler when crash happened.

Warning

FPCustomHandler relies on the underlying implementation details of Crashlytics(version 3.8.4(121)), These may be changed in future Crashlytics releases. At your own risk to use it.

When you implement your custom handlers, please do take Async-Safe Functions into considerations.

Integration

Add pod 'Crashlytics-FPCustomHandler' to your Podfile

    pod 'FPCrashHandler'

Example Swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    //These methods should be called after start Crashlytics
    FPCrashHandler.setupCustomExceptionHandler { exception in
        NSLog("==> CustomNSExceptionCrashHandler called\n")
    }

    FPCrashHandler.setupCustomSignal { (status, info, context) in
        NSLog("==> CustomSignalCrashHandler called\n");
    }
}

Example ObjC

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
	
	//These methods should be called after start Crashlytics
    [FPCrashHandler setupCustomExceptionHandler:&CustomNSExceptionCrashHandler];
    [FPCrashHandler setupCustomSignalHandler:&CustomSignalCrashHandler];
    return YES;
}
static void CustomNSExceptionCrashHandler(NSException *exception)
{
    NSLog(@"==> CustomNSExceptionCrashHandler called\n");
}

static void CustomSignalCrashHandler(int signo, siginfo_t *info, void *context)
{
    NSLog(@"==> CustomSignalCrashHandler called\n");
}

Trigger a crash

	//SIGABRT
	abort();
	
	//NSInvalidArgumentException
	NSString* str = nil;
	NSArray* array = @[str];

Or just present the debugOptionsAlert on FPCrashHandler.

You should run the demo app without Xcode's debbuger attached, then you can search the logs with "==>" here:

iOS Simulator -> Debug -> Open System Log (or press Cmd + / in iOS Simulator)

Reference

License

MIT

About

A helper class for Crashlytics to make your life easier

Topics

Resources

Packages

No packages published