IOS home button warning, is this possible?

I really don't think it can be done, but still my boss wants me to provide a link where he says so. He wants to add "are you sure you want to exit?" warning when the user clicks the home button, and if the user says no, the application will not remain inactive. This cannot be done, can it?

+5
source share
8 answers

No, you cannot do this - the application does not say this. Ask your boss if he has ever seen one example iOS application that would do this. No ... not one, I would argue.

The application can continue to perform some functions in the background - streaming music, for example, receiving location information, but no application can block the home button. If you can do this, you can block the application from closing.

A) You could not technically do this and

B) Apple will not allow it to be released on the App Store if it was a distribution route that you took

If you look at the method stubs created by Xcode when creating the application delegate

-(void)applicationWillResignActive:(UIApplication *)application

-(void)applicationWillTerminate:(UIApplication *)application

Comments are filled out on how you can use this method to pause tasks, turn off timers, reduce frame rates, save data - there is nothing about the possibility of a delay, ask the user with the message "Are you sure".

This whole idea is more likely to run counter to the iPhone / Pad / Pod-Touch user experience.

App Store ( ):

, ,

"", .

+16

, API. Apple, , - . :

  • ( , , , ).
  • . "" , , .
  • API "". , API, API Apple, - # 1 # 2 .

, , , , iOS.

, , (, ), (.. ).

. , ... , , , Apple , , ...

+2

, , . "", applicationWillResignActive, . applicationDidEnterBackground, Apple docs:

applicationDidEnterBackground: 5 , . , . ,

+2

, , , , iOS.

Apple

, . , , Apple . , , , , "" , .

+1

, IOS. , "" , .

+1

, , .

, .

, @iandotkelly, iOS5. , "".

applicationState, , .

applicationState - , appDelegate.

**

if it returns 2 then, it will identify the Home button is pressed
if it returns 1 then, it will identify the lock hardware button is pressed

**

, **applicationDidEnterBackground**

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    NSLog(@"decision >> %d",[[UIApplication sharedApplication] applicationState]);
}

!

+1

, , . , Apple " ", " ", , "", .

0

, , . iOS 7 . screenbrightness, , Home Lock.

-(void)applicationDidEnterBackground:(UIApplication *)application { if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateInactive) { NSLog(@"Sleep button pressed"); } else if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) { if ([[UIScreen mainScreen] brightness] > 0.0) NSLog(@"Home button pressed"); else NSLog(@"Sleep button pressed"); } }

, -.

0

All Articles