Prevent application terminate

Discussion in 'iOS Programming' started by ruffurs, Aug 22, 2008.

  1. macrumors newbie

    Joined:
    Aug 22, 2008
    #1
    Hello!

    I want to prevent application terminate when the user press Home Button. I want that application does nothing, whene the user press the HomeButton.

    I can output message in Console like this:

    - (void) applicationWillTerminate(UIApplication *)application {
    NSLog(@"Msg");
    }

    but i did not find how to cancel the application termination on iphone sdk. The method
    - (NSTerminateReply) applicationShouldTerminate:(NSApplication *)application {
    return NSTerminateCancel;
    }

    of course, is not working on IPhone SDK.

    Is there any similar method on iphone sdk?

    [Edited:] This software will be used on IPod Touch. There will be a lot of users, and they are supposed to use only one application.

    Thanks.
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    You cannot prevent the user terminating the application if they want to: it's their phone not yours.
     
  3. thread starter macrumors newbie

    Joined:
    Aug 22, 2008
    #3
    Actually, that device (in this case, IPod Touch) will not be users, it will be mine.
     
  4. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Well, whilst I understand why you might want to force them into using only your app there is no way to do this directly with in the SDK.

    The best suggestion I have it is to subclass UIApplication and override the terminate method (see my posts here for a likely method to override) to not actually terminate the app.

    The issue would obviously be that unless you leave yourself some sort of backdoor you won't be able to terminate the app without force-rebooting the iPod either...
     
  5. macrumors 6502a

    Joined:
    Nov 9, 2007
    #5
    A few points:

    * As you might expect, such a function doesn't exist...
    * ...nor will it ever exist.
    * What you are trying to do is stupid
    * Even if such a function existed, you could not prevent people from force-quitting by holding down the home button...
    * ...or rebooting the device (because you can't auto-run apps).

    How about you trust your users? If this isn't an option, then an iPhone/iPod Touch is probably not a suitable solution for whatever you're trying to do.
     
  6. macrumors member

    Joined:
    May 24, 2003
    #6
    I think I can understand what you're trying to do: I often find myself signing for deliveries on Windows-Mobile-based devices that presumably only run the "sign-for-deliveries" app.

    The iPhone can't be closed down like this using the SDK, I'm afraid. If you need to deploy an app in such a manner that your users cannot quit it or switch to another, then I'm afraid that the iPhone is not going to be the right device for you.
     
  7. macrumors newbie

    Joined:
    Nov 5, 2008
    #7
    how to display alert when home button pressed while app is Running

    Hi,

    Please let me know, how to display an alert message when home button is pressed on the Iphone while the application is Running


    Thanks in Advanced,
    koti
     
  8. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #8
    Even if you could, please don't.
     

Share This Page