<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/userActivity(_:isActive:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE12userActivity_8isActive_QrSS_SbySo06NSUserE0CctF"
  },
  "title" : "userActivity(_:isActive:_:)"
}
-->

# userActivity(_:isActive:_:)

Advertises a user activity type.

```
nonisolated func userActivity(_ activityType: String, isActive: Bool = true, _ update: @escaping (NSUserActivity) -> ()) -> some View
```

## Parameters

`activityType`

The type of activity to advertise.

`isActive`

When `false`, avoids advertising the activity. Defaults
to `true`.

`update`

A function that modifies the passed-in activity for
advertisement.

## Discussion

You can use `userActivity(_:isActive:_:)` to start, stop, or modify the
advertisement of a specific type of user activity.

The scope of the activity applies only to the scene or window the
view is in.

---

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)