开发者

How to get call end notification event from iPhone?

How can I tell i开发者_JS百科n my app when a phone call has ended? Also, can I get information about that call, like the duration?


That's a really good question. It might be possible to sign up to receive notifications (using UINotificationCenter calls) from UITelephony or similar. However, I don't know if that's a public or private API off the top of my head. Or if it's even possible :)

However, if you're actively using your app when the phone call starts, it will call -(void)applicationWillEnterForeground when the call is finished. As for differentiating a phone call end versus just a regular return to phone call, I don't know. But it's a start.

As for duration, just save the time stamp including seconds to NSUserDefaults when -(void)applicationWillResignActive. Then compare and do math with the time stamp when -(void)applicationWillEnterForeground. I hope this helps a bit, or at least sets you on the right track.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜