<!--
{
  "availability" : [
    "iOS: 3.0.0 - 7.0.0",
    "iPadOS: 3.0.0 - 7.0.0",
    "macOS: 10.8.0 - 10.10.0",
    "visionOS: 1.0.0 - 1.0.0",
    "watchOS: 3.0.0 - 2.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "GameKit",
  "identifier" : "/documentation/GameKit/GKSession/init(sessionID:displayName:sessionMode:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "GameKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKSession(im)initWithSessionID:displayName:sessionMode:"
  },
  "title" : "init(sessionID:displayName:sessionMode:)"
}
-->

# init(sessionID:displayName:sessionMode:)

Initializes and returns a newly allocated session.

```
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 [`GKSessionMode`](/documentation/GameKit/GKSessionMode) for possible values.

## Return Value

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

## Discussion

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

---

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)