Unwanted Communication Reporting Extension


Unwanted Communication Reporting Extension
骚扰电话报告拓展(不想要的通信报告拓展)
SMS and Call Spam Reporting
骚扰短信和骚扰电话上报

Create an app extension that lets users report unwanted SMS messages and calls as junk.
创建一个应用扩展程序,让用户将来电号码标记为骚扰电话并上报。

To report SMS messages and calls as spam, the user must enable an Unwanted Communication Reporting extension, called an SMS/Call Reporting extension in the Settings app (see Settings > Phone > SMS/Call Reporting).
要上报骚扰电话和短信,用户必须启用“骚扰电话报告拓展”,在手机设置中,找到“电话-短信/来电报告”,并勾选你想启用的“骚扰电话报告拓展”。

The user can only enable one Unwanted Communication Reporting extension at a time.
用户一次只能启用一个“骚扰电话报告拓展”。

In order to report calls, the user swipes left on an item in the Recents list and selects Report.
启用拓展之后,打开“电话”-“最近通话”,选择其中一个条目,向左滑动即可标记且上报。

For SMS messages, they press the Report Messages button when it appears in the Messages transcript. Users can also select messages by long-pressing a message and selecting additional messages, then selecting Report Messages.
至于短信,用户可以长按,然后点击“更多…”,然后点击“报告垃圾信息”,也可以在短信列表的底部,直接点击“报告所有垃圾信息”。

When the user reports an SMS message or call, the system launches your Unwanted Communication Reporting extension. Your extension gathers additional information from the user, before deciding whether to report or block the number, as shown in the figure below:
当用户上报骚扰电话和短信时,系统会启动“骚扰电话报告拓展”,在完成上报之前,你的扩展程序可以让用户填报更多信息,比如“外卖”“快递”“推销”等,如下图所示:

Specifically, the system:
1.Instantiates your extension’s ILClassificationUIExtensionViewController subclass;
2.Calls your controller’s prepare(for:) method and presents the controller to the user
Use your ILClassificationUIExtensionViewController subclass to gather data from the user. Override the prepare(for:) method to configure your controller.

具体来说,系统:
1.实例化子类:ILClassificationUIExtensionViewController;
2.调用控制器的prepare(for:)方法并将控制器呈现给用户,并从用户那里收集数据。
(你需要重写prepare方法来配置你的控制器)

The system provides a Cancel and a Done button for the controller. By default, the system disables the Done button.
系统为控制器提供了一个取消和完成按钮(如图),默认情况下,完成按钮是灰色的,无法点击。

As soon as the user has entered all the information you require, enable the Done button by setting the view controller’s isReadyForClassificationResponse property to true.
当用户选择了“外卖”“快递”“推销”等标签之后,你可以将isReadyForClassificationResponse设为true,然后“完成”按钮就可以点击了。

self.extensionContext.isReadyForClassificationResponse = true

If the user presses Done, the system calls your view controller’s classificationResponse(for:) method, passing in an ILClassificationRequest object (see the figure below)
如果用户点击“完成”,系统会调用控制器的classificationResponse方法,并传入一个对象(见下图):

Override the classificationResponse(for:) method to return a ILClassificationResponse based on the data the user has entered and information about the SMS message or call from the request object.
重写此方法,可返回一个ILClassificationResponse对象,此对象包含对应的来电/短信信息,也包含了当前页面收集到的数据信息。

The system takes different actions based on the response. For ILClassificationAction.none, the system dismisses your view controller, but doesn’t take any other action.
根据不同的ILClassificationResponse,系统会采取不同的行动。对于ILClassificationAction.none,系统将关闭页面,不执行任何其他操作。

For ILClassificationAction.reportNotJunk or ILClassificationAction.reportJunk, the system generates a report based on your response’s action and userInfo properties and then posts it to a network endpoint or sends it using an SMS message, depending on the keys specified in your extension’s Info.plist file.
对于ILClassificationAction.reportNotJunk或ILClassificationAction.reportJunk,系统将生成报告,然后将其通过网络端点发送,具体取决于您的扩展文件中指定的键。(也可以通过短信发送,这个操作太骚,此处故意忽略,不翻译)

To send a response over the network connection, you must add an associated domain to your extension. For general instructions, see Supporting associated domains. Note that you must use classificationreport instead of webcredentials when specifying the domains. You must also specify the network endpoint’s address using the ILClassificationExtensionNetworkReportDestination key in your extension’s Info.plist file.
要通过网络发送响应,您必须将关联域添加到您的扩展。至于什么是关联域,请参阅https://developer.apple.com/documentation/xcode/supporting-associated-domains。请注意,在指定域时,必须使用classificationreport而不是webcredentials。还必须在拓展应用的info.plist文件中使用ILClassificationExtensionNetworkReportDestination键指定网络端点的地址。

发表评论