Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: Is there any delegate method when the app quits due to any crash

Tags:

ios

I would like to do some interaction with my server when my app quits at the time of crash due to low memory, memory leaks etc. general crashes. I would like to know, Is there any delegate methods will be called in this scenario, so that i can contact my server quickly and immediately before the app quits due to any crash.

Thank you.

like image 982
Stella Avatar asked May 02 '13 04:05

Stella


People also ask

How do I find out which app is crashing on my Iphone?

Open the Console app, from Applications > Utilities in Finder. Select Crash Reports. Locate crash reports for your app in the list. Logs are listed by your app's binary name.

How do I find out why an app crashed?

Find your data Select an app. On the left menu, select Quality > Android vitals > Crashes and ANRs. Near the center of your screen, use the filters to help you find and diagnose issues. Alternatively, select a cluster to get more details about a specific crash or ANR error.

What is FrontBoardServices?

FrontBoardServices is nothing but the client framework to the FrontBoard system of iOS. In simple terms it is a private framework used by UIKit.


1 Answers

As you explained you need to intimate server you can contact your server immediately before the app quits due to any crash.

in that case you should set exception handler as any exception will occur you will get notify

See how can you do this

write this NSSetUncaughtExceptionHandler (&uncaughtExceptionHandler) line of code in applicationDidFixnishLaunchin Method of Appdelegate Class

 -(BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:  
  (NSDictionary*)launchOptions
 {   
    NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler); 

   EDIT:
   if( [[NSUserDefaults standardUserDefaults] boolForKey:@"isExceptionOccured"])
   {
    //call sever code here
    [[NSUserDefaults standardUserDefaults] setBool:FALSE forKey:@"isExceptionOccured"];
   }
   //rest of your code
 }


 void uncaughtExceptionHandler(NSException *exception)
  {


  NSLog(@"Exception Got %@",[exception description]);
  //do what ever you what here 
  //can save any `bool` so that as aaplication  run on immediate next launching of crash
  //could intimate any thing

  EDIT: 

  [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"isExceptionOccured"];

  }
like image 139
Kamar Shad Avatar answered Sep 20 '22 01:09

Kamar Shad