One Logo Pool Ball
FamilyControls · IOS API REFERENCE

FamilyActivityPicker

struct · iOS 15.0+ · SDK 27.1

@MainActor @preconcurrency struct FamilyActivityPicker

A view in which users specify applications, web domains, and categories without revealing their choices to the app. To prompt the user for their selection, create a binding to a ``FamilyControls/FamilyActivitySelection`` instance, and use the binding to create a ``FamilyControls/FamilyActivityPicker`` instance. You can then display the picker like any SwiftUI view. ``` swift struct ExampleView: View { @State var selection = FamilyActivitySelection() var body: some View { VStack { Image(systemName: "eye") .font(.system(size: 76.0)) .padding() FamilyActivityPicker(selection: $selection) Image(systemName: "hourglass") .font(.system(size: 76.0)) .padding() } .onChange(of: selection) { newSelection in let applications = selection.applications let categories = selection.categories let webDomains = selection.webDomains } } } ``` > Note: A `FamilyActivityPicker` shown on a parent device only displays applications and websites from authorized child devices within the Family Sharing Group. > A `FamilyActivityPicker` shown on an individually authorized device includes applications and websites from that same device. To streamline this process, call the <doc://com.apple.documentation/documentation/swiftui/view/familyactivitypicker(ispresented:selection:)> modifier on a view in your user interface. This modifier displays the picker view as a sheet over your user interface when the `isPresented` binding is `true`. ```swift struct ExampleView: View { @State var selection = FamilyActivitySelection() @State var isPresented = false var body: some View { Button("Present FamilyActivityPicker") { isPresented = true } .familyActivityPicker(isPresented: $isPresented, selection: $selection) .onChange(of: selection) { newSelection in let applications = selection.applications let categories = selection.categories let webDomains = selection.webDomains } } } ``` When you present the `FamilyActivityPicker`, the system displays a view where the user can select categories, applications, and web domains. As soon as the user confirms their selection, the system updates the `FamilyActivitySelection` binding with the user's selections. To protect the user's privacy, the system uses opaque values to represent the selections. Your app passes the selected values to the appropriate instances and methods from the <doc://com.apple.documentation/documentation/ManagedSettings> and <doc://com.apple.documentation/documentation/DeviceActivity> frameworks.

Members (2)

init · iOS 16.0+

init

TypeScript
static initHeaderTextFooterTextSelection(headerText: (string) | null, footerText: (string) | null, selection: _SwiftUICore_Binding<FamilyActivitySelection>): Promise<FamilyActivityPicker>
Swift declaration
@MainActor @preconcurrency init(headerText: String? = nil, footerText: String? = nil, selection: Binding<FamilyActivitySelection>)

Creates a new activity picker with optional header and footer text. - Parameters: - headerText: An optional string that provides text for the header of the picker view. - footerText: An optional string that provides text for the footer of the picker view. - selection: A binding that manages the user-selected categories, apps, and web domains.

init · iOS 15.0+

init

TypeScript
static initSelection(selection: _SwiftUICore_Binding<FamilyActivitySelection>): Promise<FamilyActivityPicker>
Swift declaration
@MainActor @preconcurrency init(selection: Binding<FamilyActivitySelection>)

Creates a new activity picker. - Parameters: - selection: A binding that manages the user-selected categories, apps, and web domains.

Skipped declarations

1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

FamilyActivityPicker.body

This protocol needs associated types that cannot yet cross the bridge.

All FamilyControls types →