---
title: "init(sessionID:displayName:sessionMode:)"
framework: gamekit
role: symbol
role_heading: Initializer
path: "gamekit/gksession/init(sessionid:displayname:sessionmode:)"
---

# init(sessionID:displayName:sessionMode:)

Initializes and returns a newly allocated session.

## Declaration

```swift
init!(sessionID: String!, displayName name: String!, sessionMode mode: GKSessionMode)
```

## Parameters

- `sessionID`: A unique string that identifies your application. Your sessionID should be the short name of an approved Bonjour service type. If nil, the session uses the application’s bundle identifier to create a sessionID string.
- `name`: A string identifying the user to display to other peers. If nil, the session uses the device name.
- `mode`: The mode the session should run in. See doc://com.apple.gamekit/documentation/GameKit/GKSessionMode for possible values.

## Return Value

Return Value An initialized session object, or nil if an error occurred.

## Discussion

Discussion Only sessions running with the same sessionID are visible to your session.
