---
title: "init(serviceType:session:)"
framework: multipeerconnectivity
role: symbol
role_heading: Initializer
path: "multipeerconnectivity/mcbrowserviewcontroller/init(servicetype:session:)"
---

# init(serviceType:session:)

Initializes a browser view controller using the provided service type and session.

## Declaration

```swift
convenience init(serviceType: String, session: MCSession)
```

## Parameters

- `serviceType`: The type of service to search for. This should be a short text string that describes the app’s networking protocol, in the same format as a Bonjour service type (without the transport protocol) and meeting the restrictions of https://tools.ietf.org/html/rfc6335 (section 5.1) governing Service Name Syntax. In particular, the string: Must be 1–15 characters long Can contain only ASCII lowercase letters, numbers, and hyphens Must contain at least one ASCII letter Must not begin or end with a hyphen Must not contain hyphens adjacent to other hyphens. This name should be easily distinguished from unrelated services. For example, a text chat app made by ABC company could use the service type abc-txtchat. For more details, read https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/NetServices/Articles/domainnames.html#//apple_ref/doc/uid/TP40002460.
- `session`: The multipeer session that any user-chosen peers should be invited to join.

## Return Value

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

## Discussion

Discussion This method throws an exception if the session or serviceType parameters do not contain valid objects or the specified Bonjour service type is not valid.

## See Also

### Initializing a Browser View Controller

- [init(browser:session:)](multipeerconnectivity/mcbrowserviewcontroller/init(browser:session:).md)
- [delegate](multipeerconnectivity/mcbrowserviewcontroller/delegate.md)
- [browser](multipeerconnectivity/mcbrowserviewcontroller/browser.md)
- [session](multipeerconnectivity/mcbrowserviewcontroller/session.md)
