Create an app extension that lets users report unwanted SMS messages and calls as spam.
To report SMS messages and calls, the user must enable an Unwanted Communication extension in the Settings app. They can only enable one Unwanted Communication 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 extension. Your extension gathers additional information from the user, before deciding whether to report or block the number, as shown in Figure 1.
Specifically, the system:
Instantiates your extension’s
UIExtension View Controller
Calls your controller’s
Presents the controller to the user.
ILClassification subclass to gather data from the user. Override the
prepare(for:) method to configure your controller.
The system provides a Cancel and Done button for the controller. By default, the Done button is disabled. As soon as the user has entered all the information you require, enable the Done button by setting the view controller’s
is property to
If the user presses the Cancel button, the system dismisses your view controller, as shown in Figure 2.
classification method to return a
ILClassification based on the data the user has entered and information abut the SMS message or call from the request object.
The system takes different actions based on the response you return. For
ILClassification, the system dismisses your view controller, but doesn’t take any other action, as shown in Figure 4.
ILClassification, the system generates an SMS message based on your response’s
user properties. The message’s destination is set by the
ILClassification key in your extension’s
Info file. The system then displays the SMS message to the user. The user can either send or cancel the message. Finally, the system dismisses the SMS message and your view controller (Figure 5).
ILClassification, the system generates and displays an SMS message, just like the
ILClassification action. However, after dismissing the SMS message, the system presents an alert letting the user know the number will be blocked. Finally, the system blocks the SMS or call number, and dismisses your view controller as shown in Figure 6.
Blocked numbers are added to the device’s Blocked Contact list. Users can manage this list in the Settings app.
Finally, to protect user privacy, the system always deletes your extension’s container after your extension terminates. For more information, see About the iOS File System.