I have an ios app in which I am already using Crittercism. It reports the exceptions perfectly.
My problem is that I also want those exceptions to be logged to my backend server.
I have tried a lot of things to make it happen but to no avail. Here are the list of things I tried:
- Call
NSSetUncaughtExceptionHandler(&myExceptionHandler);
If I do this, the exception is not reported in Crittercism.
- Call
NSSetUncaughtExceptionHandler(&myExceptionHandler);
Send the exception to my server.
Then call the constructor of Crittercism in myExceptionHandler
function and rethrow the exception. Doesn't work.
Call the constructor of Crittercism followed by
NSSetUncaughtExceptionHandler(&myExceptionHandler);
and inmyExceptionHandler
call[Crittercism logHandledException:exception];
. Doesn't work either.In my exception handler serialize the exception object and store it in user preferences. When the user restarts the app, call
[Crittercism logHandledException:exception];
and then send the exception to my backend server. Problem with this was, I was not able to deserialize the string to exception object. I couldn't put the stack trace inNSString
form into my exception object.
Some things I could have tried:
Let the crittercism handle the exception and then on next restart,
crittercismDidCrashOnLastLoad
will be called - but do I have the exception info present or can I access it from somewhere.I may not need to deserialize the string to exception object. I believe Crittercism is also changing the exception into a json object and sending this json object to its servers. But I am not able to find out which functions to use to send a custom json object to crittercism.
Can someone guide me on how to proceed?
I have found the solution to this. Firstly init the crittercism object using
Now define
Then,
In your custom function, do whatever you want to do with your exception and then call
Call
You can do similar things for signals.