iOS:接到电话时显示提醒?
我希望在接到电话时触发本地通知(并显示警报) - 这可能吗?通话事件可以启动应用程序或触发通知吗?
Skype 是如何被解雇的?有推送通知吗?
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
当各种事件发生时,您的应用程序委托将接收对各种 UIApplicationDelegate 协议方法的调用。其中之一是
- (void)applicationWillResignActive:(UIApplication *)application
方法,该方法会因来电或短信而调用,但也可能因其他原因而调用。请参阅 UIApplicationDelegate 协议参考更多信息。
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.
如果您的应用程序在通话时正在运行,请查看 核心电话框架。
CTCall
类提供有关通话状态的信息。我自己没有使用过这个,但你可能会发现它很有用。编辑:
CTCallCenter
允许您注册通话事件状态更改。正如我之前所说,您的应用程序需要运行才能知道某些内容发生了变化。当您的应用程序移至后台时,您可能需要请求最大后台时间(我认为现在是 10 分钟)。这些 api 仅在 iOS 4.0 及更高版本中可用。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.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.而且,为了回答你的问题中尚未有人触及的部分,Skype正在使用后台方法,专门用于使应用程序在后台保持活动状态以接收VOIP呼叫。它的一小部分实际上正在运行,等待被调用。除非您声称自己是用于 VOIP 或音频目的的后台应用程序,否则您不能这样做 - 如果您确实声称这样做,那么您最好这样做,否则您将永远不会进入应用程序商店。
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.
您能做的最好的事情就是挂接
applicationWillResignActive
方法,基本上只要您的应用程序失去焦点(这种情况发生在呼叫进入时,但也会由于其他原因发生,因此它并不完美),该方法就会被调用。请参阅:http://developer.apple。 com/library/ios/#documentation/UIKit/Reference/UIApplicationDelegate_Protocol/Reference/Reference.html
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