Detect incoming phone calls

后端 未结 3 551
悲&欢浪女
悲&欢浪女 2021-01-06 21:16

I need to determine when an incoming phone call arrives. I know that applicationWillTerminate will be called if the user takes the call and applicationWillResignActive when

相关标签:
3条回答
  • 2021-01-06 21:43

    In short - no, you can not determine if there's an incoming call or another kind of interruption in your application.

    0 讨论(0)
  • 2021-01-06 21:44

    I found this article on handling incoming calls; terminating resuming and persisting state,.

    It might help you..

    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];
    }
    
    0 讨论(0)
  • 2021-01-06 21:50

    I know this questions is really old, but in case someone else reach this question just like me, there is an audio session delegate to detect if the audio will be interrupted (mainly by a Phone call).

    For any app playing audio this approach works for detecting incoming iphone calls.

    Here is a link to Apple documentation for: Handling Audio Interruptions

    0 讨论(0)
提交回复
热议问题