<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GroupActivities",
  "identifier" : "/documentation/GroupActivities/GroupActivityAssociationInteraction",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Group Activities",
      "UIKit"
    ],
    "preciseIdentifier" : "c:@M@_GroupActivities_UIKit@objc(cs)GroupActivityAssociationInteraction"
  },
  "title" : "GroupActivityAssociationInteraction"
}
-->

# GroupActivityAssociationInteraction

An interaction configures a view’s association with the current SharePlay
group activity.

```
@MainActor @objc class GroupActivityAssociationInteraction
```

## Overview

When a group of people join a SharePlay activity with their spatial
Personas, the system selects a common, primary scene to arrange their
spatial Personas around. This association between the group activity and a
scene in your app creates a shared space for the spatial Personas to
interact in; enabling participants to gesture at the associated scene and
understand each other.
For more information about spatial Personas and SharePlay on visionOS,
see [Adding spatial Persona support to an activity](/documentation/GroupActivities/adding-spatial-persona-support-to-an-activity).

By default, the system uses your scene’s activation conditions in
concert with your activity’s [`SceneAssociationBehavior`](/documentation/GroupActivities/SceneAssociationBehavior) to select a
primary scene to associate with the activity.
You can specify a different scene or dynamically change the primary
associated scene by adding this interaction to a view and specifying that
view as the `GroupActivityAssociationKind/primary` group activity
association.

> Tip:
> When building a custom ``doc://com.apple.GroupActivities/documentation/GroupActivities/SpatialTemplate``, the primary associated scene
> is the ``doc://com.apple.GroupActivities/documentation/GroupActivities/SpatialTemplateElementPosition/app`` that each seat’s position is
> relative to.

To add the interaction to a view, use
<doc://com.apple.documentation/documentation/UIKit/UIView/addInteraction(_:)>.

```swift
// Create and store the scene association interaction
private let groupActivityAssociationInteraction = GroupActivityAssociationInteraction(
    associationKind: .primary("content-view")
)

override func viewDidLoad() {
    super.viewDidLoad()

    // Add the interaction to the view
    view.addInteraction(groupActivityAssociationInteraction)
}
```

If there are multiple scenes that are simultaneously configured with the
primary group activity association, the most recently associated scene
will be used.
For example, if your app defines two windows and both contain views with
the primary association kind, the most recently opened one will be used
as the primary scene. If that second window is subsequently closed,
the original window will be used again.

You can dynamically disable the group activity association of
a view by setting the optional `associationKind` property to `nil`.
You can later re-associate it by setting the `associationKind` to `.primary`.

```swift
func removeGroupActivityAssociation() {
   groupActivityAssociationInteraction.associationKind = nil
}
```

## Topics

### Initializers

[`init(associationKind: GroupActivityAssociationKind?)`](/documentation/GroupActivities/GroupActivityAssociationInteraction/init(associationKind:))

Creates a group activity association interaction.

### Instance Properties

[`var associationKind: GroupActivityAssociationKind?`](/documentation/GroupActivities/GroupActivityAssociationInteraction/associationKind)

An optional value that indicates the kind of group activity association,
if any.

## Relationships

### Conforms To

[`Equatable`](/documentation/Swift/Equatable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Sendable`](/documentation/Swift/Sendable)

[`UIInteraction`](/documentation/UIKit/UIInteraction)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Hashable`](/documentation/Swift/Hashable)

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)