Search code examples
iosapp-storecrash-reportsuser-permissionserror-reporting

How to report error and crashes to a server in iOS


I'm developing an iOS 7 and above app, and I'd like to know how could I report errors and crashes of the app once it is available in the App Store without having to integrate any third party to do that.

I need to report errors that may occur to a server, so I was thinking about saving the errors I'm interested in being reported (failures in getting data from services, for example) in a file, and sending the file to the server at certain moment. I don't know if this is a good approach, if it is:

1) Should I explicitly request the user permission to let the app to report errors? (alert view)

2) Could the file with the error logs be sent whenever I want, or should the user be who asks the app for sending it?

Is there a better approach to this? On the other hand, regarding app crashes: is it possible to also save them in a file?

Thanks in advance


Solution

  • Third party libraries like Crashlytics does all the good work and many people prefer that , but if you insist you can have your own service sending in the file which contains the crash details.

    The following fucntion will log the crash details to the console;

    void uncaughtExceptionHandler(NSException *exception) {    
        NSLog(@"CRASH: %@", exception);      
        NSLog(@"Stack Trace: %@", [exception callStackSymbols]);    
        // Internal error reporting
    }
    

    You can then access the console Log and write this data onto a file.

    A much more elaborate and concrete solution can be found here