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.
NowWebViewControllerDelegate - nowWebViewController(_ nowWebViewController: NowWebViewController, didReceive unsupportedUrl: URL)
Callback that notifies the host application that the web view attempted to load an unsupported URL.
| Name | Type | Description |
|---|---|---|
| nowWebViewController | NowWebViewController | Instance of NowWebViewController used when attempting to load the unsupported URL. |
| didReceive unsupportedUrl | URL | Invalid URL trying to be loaded. |
| Type | Description |
|---|---|
| None |
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)
Callback that notifies the host application that the specified Cabrillo (mobile web) flow has ended.
| Name | Type | Description |
|---|---|---|
| nowWebViewController | NowWebViewController | Instance of NowWebViewController where the flow ended. |
| didEndFlow flowName | String | Name of the Cabrillo flow that ended |
| Type | Description |
|---|---|
| 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.
| Name | Type | Description |
|---|---|---|
| nowWebViewController | NowWebViewController | Instance of NowWebViewController in which the navigation failed. |
| didFailNavigationWith error | Swift.Error | Error raised from the navigation failure. |
| Type | Description |
|---|---|
| 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, systemThemeDidChange traitCollection: UITraitCollection)
Callback that notifies the host application that the system web UI theme changed.
| Name | Type | Description |
|---|---|---|
| nowWebViewController | NowWebViewController | Instance of NowWebViewController in which the web UI theme changed. |
| traitCollection | UITraitCollection | UITraitCollection object that contains the new theme. |
| Type | Description |
|---|---|
| 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)
}
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.
| Name | Type | Description |
|---|---|---|
| nowWebViewController | NowWebViewController | Instance of NowWebViewController in which the back navigation was attempted. |
| Type | Description |
|---|---|
| None |
The following code example shows how to call this method.
func nowWebViewControllerDidRequestDismissal(_ nowWebViewController: NowWebViewController) {
navigationController?.popViewController(animated: true)
}