<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/onWebViewImmersiveEnvironmentRequest(shouldAllow:present:dismiss:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI",
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewP08_WebKit_aB0E02ondC27ImmersiveEnvironmentRequest11shouldAllow7present7dismissQrSb0dE00D4PageC9FrameInfoVYaYbScMYcc_yAK0gH0VYaYbKScMYccyAOYaYbScMYcctF"
  },
  "title" : "onWebViewImmersiveEnvironmentRequest(shouldAllow:present:dismiss:)"
}
-->

# onWebViewImmersiveEnvironmentRequest(shouldAllow:present:dismiss:)

Manages the lifecycle of immersive environments requested by websites.

```
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

A modified view that manages immersive environment lifecycle.

## Discussion

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

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)