Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

NowWebViewControllerDelegate protocol- iOS

The NowWebViewControllerDelegate protocol provides callbacks for notification of issues within the NowWebViewController processing such as when a flow ends or a navigation fails.

Parent Topic:Mobile SDK - iOS

NowWebViewControllerDelegate - nowWebViewController(_ nowWebViewController: NowWebViewController, didEndFlow flowName: String)

Callback that notifies the host application that the specified Cabrillo (mobile web) flow has ended.

NameTypeDescription
nowWebViewControllerNowWebViewControllerInstance of NowWebViewController where the flow ended.
didEndFlow flowNameStringName of the Cabrillo flow that ended
TypeDescription
None 

The following code example shows how to call this method.

func nowWebViewController(_ nowWebViewController: NowWebViewController, didEndFlow flowName: String) {
  debugPrint("ended flow named: \(flowName)")
}

NowWebViewControllerDelegate - nowWebViewController(_ nowWebViewController: NowWebViewController, didFailNavigationWith error: Swift.Error)

Callback that notifies the host application that the web view navigation has failed.

NameTypeDescription
nowWebViewControllerNowWebViewControllerInstance of NowWebViewController in which the navigation failed.
didFailNavigationWith errorSwift.ErrorError raised from the navigation failure.
TypeDescription
None 

The following code example shows how to call this method.

func nowWebViewController(_ nowWebViewController: NowWebViewController, didFailNavigationWith error: Error) {
  debugPrint("NowWebViewController encountered a navigation error: \(error.localizedDescription)")
}

NowWebViewControllerDelegate - nowWebViewController(_ nowWebViewController: NowWebViewController, didReceive unsupportedUrl: URL)

Callback that notifies the host application that the web view attempted to load an unsupported URL.

An unsupported URL could be one for a different ServiceNow instance or an absolute URL with an invalid scheme.

Note: Valid schemes are http and https.

NameTypeDescription
nowWebViewControllerNowWebViewControllerInstance of NowWebViewController used when attempting to load the unsupported URL.
didReceive unsupportedUrlURLInvalid URL trying to be loaded.
TypeDescription
None 

The following code example shows how to call this method.

func nowWebViewController(_ nowWebViewController: NowWebViewController, didReceive unsupportedUrl: URL) {
  debugPrint("nowWebViewController:receivedUnsupportedUrl: \(unsupportedUrl.absoluteString)")
}

NowWebViewControllerDelegate - nowWebViewControllerDidRequestDismissal(_ nowWebViewController: NowWebViewController)

Callback that notifies the host application that during a back navigation attempt, the stack was exhausted. The host application can then decide whether to dismiss the NowWebViewController instance.

NameTypeDescription
nowWebViewControllerNowWebViewControllerInstance of NowWebViewController in which the back navigation was attempted.
TypeDescription
None 

The following code example shows how to call this method.

func nowWebViewControllerDidRequestDismissal(_ nowWebViewController: NowWebViewController) {
  navigationController?.popViewController(animated: true)
}

NowWebViewControllerDelegate - nowWebViewController(_ nowWebViewController: NowWebViewController, systemThemeDidChange traitCollection: UITraitCollection)

Callback that notifies the host application that the system web UI theme changed.

NameTypeDescription
nowWebViewControllerNowWebViewControllerInstance of NowWebViewController in which the web UI theme changed.
traitCollectionUITraitCollectionUITraitCollection object that contains the new theme.
TypeDescription
None 

The following code example shows how to override the systemThemeDidChange() delegate function to call the updateTheme() function to apply theme changes when the system theme changes.

func nowWebViewController(_ nowWebViewController: NowWebViewController, systemThemeDidChange traitCollection: UITraitCollection) {

  /// Called when the system changes between dark and light mode

    /// You can call the corresponding updateTheme() method here to change the UI theme based on System Theme
    nowWebViewController.updateTheme(themeColors: traitCollection.userInterfaceStyle == .dark ? DarkNowWebTheme() : LightNowWebTheme())
      print(“System Theme Did Change)
}