Contents

WKUserContentController

An object for managing interactions between JavaScript code and your web view, and for filtering content in your web view.

Declaration

@MainActor class WKUserContentController

Overview

A WKUserContentController object provides a bridge between your app and the JavaScript code running in the web view. Use this object to do the following:

  • Inject JavaScript code into webpages running in your web view.

  • Install custom JavaScript functions that call through to your app’s native code.

  • Specify custom filters to prevent the webpage from loading restricted content.

Create and configure a WKUserContentController object as part of your overall web view setup. Assign the object to the userContentController property of your WKWebViewConfiguration object before creating your web view.

Topics

Adding and Removing Custom Scripts

Adding and Removing Message Handlers

Adding and Removing Content Rules

Initializers

See Also

Page content