The principal class for a filter data provider extension.
- iOS 9.0+
- macOS 10.15+
- Mac Catalyst 13.0+
Network content is delivered to the Filter Data Provider in the form of
NEFilter objects. Each
NEFilter object corresponds to a network connection opened by an application running on the device. The Filter Data Provider can choose to pass or block the data when it receives a new flow, or it can ask the system to see more of the flow’s data in either the outbound or inbound direction before making a pass or block decision.
In addition to passing or blocking network data, the Filter Data Provider can tell the system that it needs more information before it can make a decision about a particular flow of data. The system will then ask the Filter Control Provider to update the current set of rules and place them in a location on disk that is readable from the Filter Data Provider extension.
NEFilter object is originated from a WebKit browser object, the Filter Data Provider can affect the user experience in the following ways:
If the Filter Data Provider chooses to block the web page, then a special “block” page is displayed in the WebKit browser object informing the user that their attempt to access the content was blocked. The Filter Data Provider can choose to add a link to this block page, giving the user the option of requesting access to the content.
If the Filter Data Provider chooses to allow the web page, then it can also specify that a string be appended to the web page URL. This allows the Filter Data Provider to direct the WebKit browser object to a “safe” version of the web page.
To protect the user’s privacy, the Filter Data Provider extension sandbox prevents the extension from moving network content outside of its address space.
Creating a Filter Data Provider Extension
Filter Data Providers run as App Extensions for the
com extension point.
To create a Filter Data Provider extension, first create a new App Extension target in your project.
For an example of an Xcode build target for this app extension, see the SimpleTunnel: Customized Networking Using the NetworkExtension Framework sample code project.
Once you have a Filter Data Provider extension target, create a subclass of
NEFilter. Then set the
NSExtension key in the the extension’s
Info to the name of your subclass.
If it is not done already, set the
NSExtension key in the extension’s
Here is an example of the
NSExtension dictionary in a Filter Data Provider extension’s
Finally, add your Filter Data Provider extension target to your app’s Embed App Extensions build phase.
To create a Filter Data Provider extension, you must first create a subclass of
NEFilter and override the methods listed below.