Detect Incoming Phone Calls

I need to determine when an incoming phone call will arrive. I know that applicationWillTerminate will be called if the user accepts the call and applicationWillResignActive when a pop-up window appears with a confirmation message for the call:

-applicationWillTerminate is also called when the application leaves the user’s request or the battery is about to die
-applicationWillResignActive is also called when UIViewAlert is displayed .

thanks

+3
source share
3 answers

In short - no, you cannot determine if there is an incoming call or other type of interruption in your application.

+5

; ,

.

http://www.tomwhitson.co.uk/blog/2009/04/handling-interuptions-to-your-app/

(void)applicationWillResignActive:(UIApplication *)application{
        //our app is going to loose focus since thier is an incoming call
        [self pauseGame];
}

(void)applicationDidBecomeActive:(UIApplication *)application{
        //the user declined the call and is returning to our app
        [self resumeGame];
}

(void)applicationWillTerminate:(UIApplication*)application{
        //the user answered the call (or quit the app) so save the
        //game as we are shutting down
        [self saveGameState];
}
+4

, , - , , , , ( , ).

, , iphone.

Here is a link to Apple's documentation for: Handling audio interruptions

+3
source

Source: https://habr.com/ru/post/1722992/


All Articles