Detect incoming phone calls

后端 未结 3 575
悲&欢浪女
悲&欢浪女 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: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];
    }
    

提交回复
热议问题