开发者

Is there an NSNotification for phone call status

开发者 https://www.devze.com 2023-03-18 22:55 出处:网络
Is there an NSNotification we can o开发者_如何学JAVAbserve for when the device is on/off the phone? The NotificationCenter doesn\'t send out any notifications abou this, but take a look at the CTCallC

Is there an NSNotification we can o开发者_如何学JAVAbserve for when the device is on/off the phone?


The NotificationCenter doesn't send out any notifications abou this, but take a look at the CTCallCenter class introduced in iOS 4. It has a callEventHandler property that you can assign a block of code to, and gets called with call state info.

There is a limitation in that the handler only gets called when your app is in the foreground (or being taken out of the foreground when a call comes in), but it tells you if the user is dialing (CTCallStateDialing), receiving a call (CTCallStateIncoming), answering/connecting (CTCallStateConnecting) or hanging up on a call (CTCallStateDisconnected).


There isn't one that I'm aware of, but if the issue is that you want to know about the change in status bar then you can observe UIApplicationWillChangeStatusBarFrameNotification (as documented towards the bottom of the UIApplication documentation) and get a new rect from the relevant userInfo whenever a change occurs.

0

精彩评论

暂无评论...
验证码 换一张
取 消