1

when user presses home button the app should relaunch or it should not allow user to terminate. what is the possible way to do this? The app should remain on ipad unless user quits the app from inside the application not from home button.

I am considering the termination of app if it crashes or some other reasons that is ok app should quit no doubt, but not normally as user press home button the app should relaunch.

ashish
  • 474
  • 7
  • 16

3 Answers3

4

There is no way to do this. It would be a horrible user experience anyways, and as such, not encouraged.

bevacqua
  • 47,502
  • 56
  • 171
  • 285
  • I have seen this feature in one application and my requirement is like that. This is possible otherwise this app should not have that feature. "MenuPad" app. – ashish Dec 15 '10 at 13:53
  • I just downloaded "MenuPad" and pressing the home button does quit the app. I tested on iOS 4.2. If they had prevented the home button from quitting the app they would not be on the app store. Apple would have rejected the app. – Jasarien Dec 15 '10 at 14:35
  • Also it's "relaunch when closed" option has no effect on iOS 4.2 either - the fact that this was possible was obviously considered a bug by Apple and fixed. – Jasarien Dec 15 '10 at 14:37
  • in that MenuPad app on the top there is an icon menupad just double tap it it will open one panel with option "Relauch app when closed" set it on and then check... – ashish Dec 15 '10 at 14:41
1

This behavior will with 99% certainty get your app rejected on the App Store.

The normal behavior a user (and Apple) expects is to have the app quit only when the home button is pressed. Any other means of quitting an app, including special buttons, excessive crashes, etc. will flag it for rejection.

Claus Broch
  • 9,212
  • 2
  • 29
  • 38
0

You can do this only for iOS 3.2 In applicationWillTerminate do

NSString *UrlString = [NSString stringWithString: @"yourAppSchema:"];
    [application openURL:[NSURL URLWithString:[UrlString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]]]; 

First you need to update your Info.plist of your app to support an url schema

<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>yourAppSchema</string>
            </array>
            <key>CFBundleURLName</key>
            <string>com.yourCompany.yourAppSchema</string>
        </dict>
    </array>

The way you do this is to put your iPad in something like This And also read this thread.

Community
  • 1
  • 1
Alex Terente
  • 12,006
  • 5
  • 51
  • 71
  • when user presses home button app enters in background state this delegate is called - (void)applicationDidEnterBackground:(UIApplication *)application so here that url launch wont open the app again unless it comes in active state. - (void)applicationWillTerminate:(UIApplication *)application this will be called only when user removes the app from dock. – ashish Dec 15 '10 at 13:59
  • And in this delegate you reopen your app. This is the only way to do this. There is no other way to disable home button. I have posted an bug to Apple and here is the response "After further investigation it has been determined that this is a known issue, which is currently being investigated by engineering." – Alex Terente Dec 15 '10 at 14:08
  • but in iOS 4.2 even if we write custom url in - (void)applicationWillTerminate:(UIApplication *)application it wont get executed. any reasons for that. My url scheme is already set that I checked by opening that in safari app – ashish 6 mins ago – ashish Dec 15 '10 at 14:19