objective-c iPhone 应用程序可以阻止电话吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/884289/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 21:34:43  来源:igfitidea点击:

Can an iPhone app block phone calls?

iphoneobjective-cxcode

提问by

Is it possible to write an application that will block incoming and outcoming phone calls? Or is the iPhone locked down too much? Thanks!

是否可以编写一个应用程序来阻止来电和来电?还是 iPhone 被锁定太多了?谢谢!

采纳答案by Rob Napier

EDIT: See Rajan Maheshwari's answer below. CallKit now provides this. Even things that seemed they would never change, can change eventually.

编辑:请参阅下面的 Rajan Maheshwari 的回答。CallKit 现在提供了这个。即使是看起来永远不会改变的事情,最终也会改变。



Anything that modifies a user's ability to make or receive phone calls is going to run afoul of Apple's basic approach to third-party apps. There are a lot of things that are questionable and you might get away with. Blocking calls is clearly forbidden.

任何改变用户拨打或接听电话能力的行为都将违反 Apple 对第三方应用程序的基本方法。有很多事情是有问题的,你可能会侥幸逃脱。阻塞呼叫是明确禁止的。

回答by Rajan Maheshwari

It is now possible to detect and block unwanted phone calls from iOS 10and above.

现在可以检测和阻止来自iOS 10及更高版本的不需要的电话。

See the CallKitframework

查看CallKit框架

The CallKit framework (CallKit.framework) lets VoIP apps integrate with the iPhone UI and give users a great experience. Use this framework to let users view and answer incoming VoIP calls on the lock screen and manage contacts from VoIP calls in the Phone app's Favorites and Recents views.

CallKit also introduces app extensions that enable call blocking and caller identification. You can create an app extension that can associate a phone number with a name or tell the system when a number should be blocked.

CallKit 框架 (CallKit.framework) 允许 VoIP 应用程序与 iPhone UI 集成并为用户提供出色的体验。使用此框架可让用户在锁定屏幕上查看和接听传入的 VoIP 呼叫,并在电话应用程序的收藏夹和最近的视图中管理来自 VoIP 呼叫的联系人。

CallKit 还引入了支持呼叫阻止和呼叫者识别的应用程序扩展。您可以创建一个应用扩展,将电话号码与姓名相关联,或者告诉系统何时应该阻止某个号码。

回答by Kakshil Shah

It is possible in iOS 10.

在 iOS 10 中是可能的。

Here's how to do it ->

这是如何做到的->

1.Create a call directory extensionenter image description here

1.创建呼叫目录扩展在此处输入图片说明

2.Block the incoming call ->

2.阻止来电 ->

class CustomCallDirectoryProvider: CXCallDirectoryProvider {
    override func beginRequest(with context: CXCallDirectoryExtensionContext) {
        let blockedPhoneNumbers: [CXCallDirectoryPhoneNumber] = [ phone Numbers here with country code! ]
        for phoneNumber in blockedPhoneNumbers.sorted(by: <) {
            context.addBlockingEntry(withNextSequentialPhoneNumber: phoneNumber)
        }

        context.completeRequest()
    }
}

Note: If you are using callKit to receive incoming calls then there is no need to manually block other calls.

注意:如果您使用 callKit 接听来电,则无需手动阻止其他来电。

Link -> https://developer.apple.com/reference/callkit

链接 -> https://developer.apple.com/reference/callkit

回答by MikeJ

A number of events will potentially interrupt an application - incoming call, SMS message or calendar alert. If the user ignores the interruption your application will continue running. If not, it will terminate.

许多事件可能会中断应用程序 - 来电、短信或日历提醒。如果用户忽略中断,您的应用程序将继续运行。如果没有,它将终止。

See Apple docsfor more details.

有关更多详细信息,请参阅Apple 文档

回答by e2-e4

An app has not access to the phone feature, and has no way to block a call.
The alternative is to wait for Apple to offer that feature in the future.

应用程序无法访问电话功能,也无法阻止呼叫。
另一种选择是等待 Apple 将来提供该功能。

In the meantime, you can

在此期间,您可以

  • Ask your provider - some providers do that
  • Create a custom ring tone (silent) to be associated to some number (no ring).
  • 询问您的提供商 - 有些提供商会这样做
  • 创建自定义铃声(静音)以与某个号码(无铃声)相关联。