iOS:接到电话时显示提醒?

发布于 2024-10-26 10:26:00 字数 98 浏览 2 评论 0原文

我希望在接到电话时触发本地通知(并显示警报) - 这可能吗?通话事件可以启动应用程序或触发通知吗?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

忘羡 2024-11-02 10:26:00

当各种事件发生时,您的应用程序委托将接收对各种 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.

羞稚 2024-11-02 10:26:00

如果您的应用程序在通话时正在运行,请查看 核心电话框架CTCall 类提供有关通话状态的信息。我自己没有使用过这个,但你可能会发现它很有用。

extern NSString const *CTCallStateDialing;
extern NSString const *CTCallStateIncoming;
extern NSString const *CTCallStateConnected;
extern NSString const *CTCallStateDisconnected;

编辑:

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.

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.

冷情妓 2024-11-02 10:26:00

而且,为了回答你的问题中尚未有人触及的部分,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.

妳是的陽光 2024-11-02 10:26:00

您能做的最好的事情就是挂接 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文