PDA

View Full Version : Prevent application terminate




ruffurs
Aug 22, 2008, 05:20 AM
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.



robbieduncan
Aug 22, 2008, 05:22 AM
You cannot prevent the user terminating the application if they want to: it's their phone not yours.

ruffurs
Aug 22, 2008, 05:27 AM
You cannot prevent the user terminating the application if they want to: it's their phone not yours.

Actually, that device (in this case, IPod Touch) will not be users, it will be mine.

robbieduncan
Aug 22, 2008, 05:55 AM
Actually, that device (in this case, IPod Touch) will not be users, it will be mine.

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 (http://forums.macrumors.com/showthread.php?p=6066427) 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...

Luke Redpath
Aug 22, 2008, 08:36 AM
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.

grimjim
Aug 25, 2008, 04:28 AM
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.

tskoti
Mar 30, 2009, 06:24 PM
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

dejo
Mar 30, 2009, 06:34 PM
Please let me know, how to display an alert message when home button is pressed on the Iphone while the application is Running
Even if you could, please don't.