---
title: "userActivity(_:isActive:_:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/useractivity(_:isactive:_:)"
---

# userActivity(_:isActive:_:)

Advertises a user activity type.

## Declaration

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

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.

## See Also

### Sending and receiving user activities

- [Restoring your app’s state with SwiftUI](swiftui/restoring-your-app-s-state-with-swiftui.md)
- [userActivity(_:element:_:)](swiftui/view/useractivity(_:element:_:).md)
- [onContinueUserActivity(_:perform:)](swiftui/view/oncontinueuseractivity(_:perform:).md)
