Contents

GroupSession

A session for an in-progress activity that synchronizes content among participant devices.

Declaration

final class GroupSession<ActivityType> where ActivityType : GroupActivity

Mentioned in

Overview

A GroupSession object contains details about the user’s currently selected activity, its status, and its participants. When a participant engages in an activity, the system binds a session to that activity for you. You use the session object to synchronize your app’s activity-related content, including your app’s UI.

You don’t create GroupSession objects directly. Instead, the system creates sessions and makes them available to your app asynchronously. Use the AsyncSequence type returned by the sessions() method of your activity to retrieve new sessions when they become available.

Before the system can create a session object, your app must create a GroupActivity object and activate it. For information about how to configure group activities, see GroupActivity.

Start and Stop the Session

When you receive a new session object, it’s initially in the GroupSession.State.waiting state. As soon as your app is ready to begin the associated activity, call the session’s join() method. Joining a session validates the connection and starts the synchronization process between the current device and other participants’ devices. If your app successfully joins the session, the session transitions to the GroupSession.State.joined state.

When the user quits your app, or navigates away from the shared activity, call the session’s leave() method. Leaving a session gracefully transitions it to the GroupSession.State.invalidated(reason:) state, and informs the system that the user isn’t currently engaged in the activity.

Topics

Getting the current session

Joining and leaving the session

Accessing the shared activity

Getting the session details

Getting the participants

Getting the scene-association identifier

Getting the participant’s attention

Notifying participants of playback changes

Structures

Instance Properties

Instance Methods

See Also

Session management