当 iPhone 中有来电和去电时,我们可以触发事件吗?
当 iPhone 上的来电和去电结束时,我可以触发事件吗?事件的一个示例是调用 Web 服务。
Can I fire an event when ever there is Incoming and Outgoing call ends on iphone? Axample of an event is calling a webservice .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,您可以,但不一定立即。
有一个名为 CoreTelephony 框架的框架,它有一个
CTCallCenter
类。此类的属性之一是callEventHandler
属性。当电话呼叫状态发生变化时,此块就会被触发。例如:确实你能用它做的就是这些。您无法访问任何电话号码。唯一有用的信息是
CTCall
上的标识符属性,以便您唯一地标识CTCall
对象。注意:
除非您的应用位于前台,否则不会调用此事件处理程序!如果您在应用程序处于后台时拨打和接听电话,则事件处理程序将不会触发直到您的应用程序再次激活,此时(根据上面链接的文档)将调用事件处理程序当应用程序在后台时,每次调用改变状态一次。
Yes you can, but not necessarily immediately.
There is a framework, called the CoreTelephony framework, which has a
CTCallCenter
class. One of the properties on this class is thecallEventHandler
property. This is a block that gets fired when then state of a phone call changes. For example:That's really about all you can do with this. You don't get access to any phone numbers. The only other useful tidbit of information is an identifier property on
CTCall
so you uniquely identify aCTCall
object.CAUTION:
This event handler is not invoked unless your app is in the foreground! If you make and receive calls while the app is backgrounded, the event handler will not fire until your app becomes active again, at which point (according to the documentation linked to above) the event handler will get invoked once for each call that has changed state while the app was in the background.
不会,但当这些事件发生时,您确实会回调到应用程序。
No but you do get callbacks into the app when those events happen.
不可以。从当前的 SDK 来看,这是不可能的。苹果不允许应用程序有这样的钩子。
No. As of the current SDK, this is not possible. Apple does not allow apps to have such hooks.