---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# NowWebViewControllerDelegate protocol - iOS

# NowWebViewControllerDelegate protocol - iOS {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 minutes to read

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

## NowWebViewControllerDelegate - nowWebViewController(_ nowWebViewController:
NowWebViewController, didReceive unsupportedUrl: URL) {#ariaid-title2}

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.
{#NWVCD-nowWebViewCont_didReceive__table_xwc_vsv_wqb__entry__3}

| Name | Type | Description |
|-|-|-|
| nowWebViewController | [NowWebViewController](https://servicenow-prod.fluidtopics.net/kQ_D9LfG2KCD4f7fcd7ZkQ#NWebViewControlleriOSAPI "The NowWebViewController class provides functions that enable you to manage a web viewer.") | Instance of NowWebViewController used when attempting to load the unsupported URL. |
| didReceive unsupportedUrl | URL | Invalid URL trying to be loaded. |
[Table 1. Parameters]

{#NWVCD-nowWebViewCont_didReceive__table_xwc_vsv_wqb} {#NWVCD-nowWebViewCont_didReceive__table_ywc_vsv_wqb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 2. Returns]

{#NWVCD-nowWebViewCont_didReceive__table_ywc_vsv_wqb}  
The following code example shows how to call this method.

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

## NowWebViewControllerDelegate - nowWebViewController(_ nowWebViewController:
NowWebViewController, didEndFlow flowName: String) {#ariaid-title3}

Callback that notifies the host application that the specified Cabrillo (mobile web)
flow has ended.
{#NWVCD-nowWebViewCont_EndFlow__table_fkt_tqv_wqb__entry__3}

| Name | Type | Description |
|-|-|-|
| nowWebViewController | [NowWebViewController](https://servicenow-prod.fluidtopics.net/kQ_D9LfG2KCD4f7fcd7ZkQ#NWebViewControlleriOSAPI "The NowWebViewController class provides functions that enable you to manage a web viewer.") | Instance of NowWebViewController where the flow ended. |
| didEndFlow flowName | String | Name of the Cabrillo flow that ended |
[Table 3. Parameters]

{#NWVCD-nowWebViewCont_EndFlow__table_fkt_tqv_wqb} {#NWVCD-nowWebViewCont_EndFlow__table_gkt_tqv_wqb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 4. Returns]

{#NWVCD-nowWebViewCont_EndFlow__table_gkt_tqv_wqb}  
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) {#ariaid-title4}

Callback that notifies the host application that the web view navigation has
failed.
{#NWVCD-nowWebViewCont_FailNav__table_y4z_csv_wqb__entry__3}

| Name | Type | Description |
|-|-|-|
| nowWebViewController | [NowWebViewController](https://servicenow-prod.fluidtopics.net/kQ_D9LfG2KCD4f7fcd7ZkQ#NWebViewControlleriOSAPI "The NowWebViewController class provides functions that enable you to manage a web viewer.") | Instance of NowWebViewController in which the navigation failed. |
| didFailNavigationWith error | Swift.Error | Error raised from the navigation failure. |
[Table 5. Parameters]

{#NWVCD-nowWebViewCont_FailNav__table_y4z_csv_wqb} {#NWVCD-nowWebViewCont_FailNav__table_z4z_csv_wqb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 6. Returns]

{#NWVCD-nowWebViewCont_FailNav__table_z4z_csv_wqb}  
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, systemThemeDidChange traitCollection: UITraitCollection) {#ariaid-title5}

Callback that notifies the host application that the system web UI theme changed.
{#NWVCD-nowWebViewCont_sysThmChg__table_tr3_4tw_x2c__entry__3}

| Name | Type | Description |
|-|-|-|
| nowWebViewController | [NowWebViewController](https://servicenow-prod.fluidtopics.net/kQ_D9LfG2KCD4f7fcd7ZkQ#NWebViewControlleriOSAPI "The NowWebViewController class provides functions that enable you to manage a web viewer.") | Instance of NowWebViewController in which the web UI theme changed. |
| traitCollection | [UITraitCollection](https://developer.apple.com/documentation/uikit/uitraitcollection) | UITraitCollection object that contains the new theme. |
[Table 7. Parameters]

{#NWVCD-nowWebViewCont_sysThmChg__table_tr3_4tw_x2c} {#NWVCD-nowWebViewCont_sysThmChg__table_ur3_4tw_x2c__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 8. Returns]

{#NWVCD-nowWebViewCont_sysThmChg__table_ur3_4tw_x2c}  
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)
    }

## NowWebViewControllerDelegate - nowWebViewControllerDidRequestDismissal(_
nowWebViewController: NowWebViewController) {#ariaid-title6}

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.
{#NWVCD-nowWebViewContDidReqDismiss__table_xs2_4vv_wqb__entry__3}

| Name | Type | Description |
|-|-|-|
| nowWebViewController | [NowWebViewController](https://servicenow-prod.fluidtopics.net/kQ_D9LfG2KCD4f7fcd7ZkQ#NWebViewControlleriOSAPI "The NowWebViewController class provides functions that enable you to manage a web viewer.") | Instance of NowWebViewController in which the back navigation was attempted. |
[Table 9. Parameters]

{#NWVCD-nowWebViewContDidReqDismiss__table_xs2_4vv_wqb} {#NWVCD-nowWebViewContDidReqDismiss__table_ys2_4vv_wqb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 10. Returns]

{#NWVCD-nowWebViewContDidReqDismiss__table_ys2_4vv_wqb}  
The following code example shows how to call this method.

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


