iOS:接到电话时显示警报?

人气:419 发布:2022-10-16 标签: iphone ios notifications call uilocalnotification

问题描述

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

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?

Skype 是如何被解雇的?使用推送通知?

How is skype fired? With push notifications?

谢谢

推荐答案

如果您的应用程序在调用时正在运行,请查看 CoreTelephony 框架.CTCall 类提供有关呼叫状态的信息.我自己没有用过这个,但你可能会发现它很有用.

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;

CTCallCenter 允许您注册呼叫事件状态更改.正如我之前所说,您的应用程序需要运行才能知道某些事情发生了变化.当您的应用程序移至后台时,您可能想要请求最大后台时间(我认为现在是 10 分钟).这些 api 仅在 iOS 4.0 及更高版本中可用.

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.

583