iOS: showing an alert when getting a call?

后端 未结 4 972
无人共我
无人共我 2021-01-01 07:19

I would like a local notification to be fired when a call is received (and to show an alert) - is this possible? Can a call event get an app to launch or a notification to b

相关标签:
4条回答
  • 2021-01-01 07:41

    And, to answer the part of your question nobody's touched yet, Skype is using backgrounding methods specifically meant to keep an app alive in the background to receive VOIP calls. A little bit of it is actually running, waiting to be called. Unless you claim to be a backgrounding app for VOIP or audio purposes, you can't do that--and if you DO claim that, you better be DOING it, or you'll never hit the app store.

    0 讨论(0)
  • 2021-01-01 07:54

    The best you can do is hook the applicationWillResignActive method, which gets called basically whenever your app loses focus (which happens when a call comes in, but also happens for other reasons, so it's not perfect).

    See: http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIApplicationDelegate_Protocol/Reference/Reference.html

    0 讨论(0)
  • 2021-01-01 08:01

    If your application is running while a call is in place check out the CoreTelephony Framework. The CTCall class provides information about the call state. I have not used this myself but you may find it useful.

    extern NSString const *CTCallStateDialing;
    extern NSString const *CTCallStateIncoming;
    extern NSString const *CTCallStateConnected;
    extern NSString const *CTCallStateDisconnected;
    

    Edit:

    The CTCallCenter allows you to register for call event state changes. As I said before your application will need to be running to know that something has changed. You may want to request the maximum backgrounding time (I think it is 10 minutes now) when your application is moved to the background. These api's are only available in iOS 4.0 and later.

    0 讨论(0)
  • 2021-01-01 08:03

    Your application delegate will receive calls to various UIApplicationDelegate protocol methods when various events happen. One of these is the - (void)applicationWillResignActive:(UIApplication *)application method, which is called for incoming calls or text messages, but could be called for other reasons as well.

    See the UIApplicationDelegate protocol reference for more information.

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