Search code examples
iosiphoneios6sdk

Want to save application status at server


I am having issue when trying to call web service in - (void)applicationWillTerminate:(UIApplication *)application this method. Some time its give the response but sometime not.

anyway to get status at server side that my application is closed?


Solution

  • from the docs of applicationWillTerminate:

    Your implementation of this method has approximately five seconds to perform any tasks and return. If the method does not return before time expires, the system may kill the process altogether.

    My guess: your call to the webservice is too slow so the process is getting killed. That matches your description (sometimes the call is getting through, sometimes it isn't) How you can get around this depends on your app's overall achitecture.

    Heres a loink to the docs: https://developer.apple.com/library/ios/documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIApplicationDelegate/applicationWillTerminate: