Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

force application to terminate in iPhone

I am developing an iPhone application which is completely based on web data.

If it is not connected to the internet, the application is of no use.

So, I want to terminate the application when connection is not found.

NSURL *tmpURl=[NSURL URLWithString:[NSString stringWithFormat:@"%@search.php",[iGolfAppDelegate getServerPath]]];
    NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:tmpURl];
    con=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
    if(con){
        myWebData=[[NSMutableData data] retain];    
    } else { 
        //Yes I will provide two buttons on alertview "retry" & "close", & when user
        //taps on "close" => application should terminate.
        // i will send alertview & when user taps on button close then
        // what to write for terminating application?
        // Ok Ok. Don't terminate. User will terminate.
        // user is owner of iPhone 
        // let him choose what to do
        // wait till wifi connects
    }

The question is how to terminate the application?

Is exit(0) only the option for terminating application or is there any other option available?

like image 540
Sagar Kothari Avatar asked Dec 03 '09 18:12

Sagar Kothari


People also ask

How do I close an app that won't quit?

On iOS and Android devices, long-press the Home button and then swipe an app's preview card upward on iOS or to the right on Android to force quit.


1 Answers

Apple is is absolutely clear about this topic:

There is no API provided for gracefully terminating an iPhone application. Under the iPhone OS, the user presses the Home button to close applications. Should your application have conditions in which it cannot provide its intended function, the recommended approach is to display an alert for the user that indicates the nature of the problem and possible actions the user could take - turning on WiFi, enabling Location Services, etc. Allow the user to terminate the application at their own discretion.

See Technical Q&A QA1561

like image 84
Nikolai Ruhe Avatar answered Oct 03 '22 15:10

Nikolai Ruhe