2

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 be fired?

How is skype fired? With push notifications?

Thanks

Alex1987
  • 9,397
  • 14
  • 70
  • 92

4 Answers4

2

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.

Greg
  • 33,450
  • 15
  • 93
  • 100
  • It looks like this CoreTelephony introduced the ability to do this in iOS 4.0+ as long as the app is running. http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Reference/CTCallCenter/Reference/Reference.html#//apple_ref/doc/uid/TP40009604 – Joe Mar 22 '11 at 20:39
  • Thanks Joe. I've updated my answer to remove the erroneous portion. – Greg Mar 22 '11 at 20:46
  • No problem I will be able to +1 ya again once the asker selects an answer since I have yet to test that framework. – Joe Mar 22 '11 at 20:51
1

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.

Joe
  • 56,979
  • 9
  • 128
  • 135
1

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.

Dan Ray
  • 21,623
  • 6
  • 63
  • 87
-1

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

MusiGenesis
  • 74,184
  • 40
  • 190
  • 334