Skip to main content

Registering WebView

Starting from NAM iOS SDK version 8.2.0, any WKWebView that may display ads via the NAM Web SDK must be registered. This is a key feature for improving ad targeting accuracy and enhancing ad revenue in your app by enabling communication with websites that use the Web SDK.

If you are using WKWebView, including in web apps, you must apply the GFPAdManager.register(_:) interface. If there are N web views, you must apply it to all N web views.

How to Register a WebView

Apply GFPAdManager.register(_ webView: WKWebView) to the target web view. All subsequent ad targeting operations are handled automatically within the SDK.

  • It is recommended to register the WebView before rendering it.
  • This operation does not modify any settings on the WebView instance, nor does it store or retain a reference to the WebView instance.
let webView = WKWebView()
GFPAdManager.register(webView)

The Cookie Accept Policy of the WebView must be set to at least .onlyFromMainDocumentDomain; .always is recommended whenever possible.

HTTPCookieStorage.shared.cookieAcceptPolicy = .always

Checking WebView Registration Status

GFPAdManager.examineWebViewStatus(webView) { javaScriptError, results in
let isRegistered = results["isRegistered"] as? Bool ?? false
}