---
title: "onWebViewImmersiveEnvironmentRequest(shouldAllow:present:dismiss:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/onwebviewimmersiveenvironmentrequest(shouldallow:present:dismiss:)"
---

# onWebViewImmersiveEnvironmentRequest(shouldAllow:present:dismiss:)

Manages the lifecycle of immersive environments requested by websites.

## Declaration

```swift
nonisolated func onWebViewImmersiveEnvironmentRequest(shouldAllow: @escaping @MainActor @Sendable (WebPage.FrameInfo) async -> Bool, present: @escaping @MainActor @Sendable (WebPage.ImmersiveEnvironment) async throws -> Void, dismiss: @escaping @MainActor @Sendable (WebPage.ImmersiveEnvironment) async -> Void) -> some View

```

## Parameters

- `shouldAllow`: An async closure called when a website requests an immersive environment. This can be used to request user consent or apply custom authorization logic. It receives the source WebPage.FrameInfo and should return true to allow the environment presentation, or false to deny it.
- `present`: An async throwing closure called after the environment has loaded and is ready for presentation. It receives the WebPage.ImmersiveEnvironment. Use this to open an Immersive Space containing a WebViewImmersiveEnvironmentView initialized with this environment. If another immersive space is already being presented, dismiss it first. This closure should return after the presentation transition completes.
- `dismiss`: An async closure called when the website or the application asks to dismiss the immersive environment. It receives the WebPage.ImmersiveEnvironment to dismiss. This closure should return after the dismissal transition completes.

## Return Value

Return Value A modified view that manages immersive environment lifecycle.

## Discussion

Discussion Use this modifier to control authorization, presentation, and dismissal of immersive environments from websites.

## See Also

### Displaying web content

- [WebView](webkit/webview-swift.struct.md)
- [WebPage](webkit/webpage.md)
- [webViewBackForwardNavigationGestures(_:)](swiftui/view/webviewbackforwardnavigationgestures(_:).md)
- [webViewContentBackground(_:)](swiftui/view/webviewcontentbackground(_:).md)
- [webViewContextMenu(menu:)](swiftui/view/webviewcontextmenu(menu:).md)
- [webViewElementFullscreenBehavior(_:)](swiftui/view/webviewelementfullscreenbehavior(_:).md)
- [webViewLinkPreviews(_:)](swiftui/view/webviewlinkpreviews(_:).md)
- [webViewMagnificationGestures(_:)](swiftui/view/webviewmagnificationgestures(_:).md)
- [webViewOnScrollGeometryChange(for:of:action:)](swiftui/view/webviewonscrollgeometrychange(for:of:action:).md)
- [webViewScrollInputBehavior(_:for:)](swiftui/view/webviewscrollinputbehavior(_:for:).md)
- [webViewScrollPosition(_:)](swiftui/view/webviewscrollposition(_:).md)
- [webViewTextSelection(_:)](swiftui/view/webviewtextselection(_:).md)
