<!--
{
  "availability" : [
    "iOS: 7.0.0 - 27.0.0",
    "iPadOS: 7.0.0 - 27.0.0",
    "macCatalyst: 13.1.0 - 27.0.0",
    "macOS: 10.10.0 - 27.0.0",
    "tvOS: 10.0.0 - 27.0.0",
    "visionOS: 1.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "MultipeerConnectivity",
  "identifier" : "/documentation/MultipeerConnectivity/MCNearbyServiceAdvertiser",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Multipeer Connectivity"
    ],
    "preciseIdentifier" : "c:objc(cs)MCNearbyServiceAdvertiser"
  },
  "title" : "MCNearbyServiceAdvertiser"
}
-->

# MCNearbyServiceAdvertiser

The `MCNearbyServiceAdvertiser` class publishes an advertisement for a specific service that your app provides through the Multipeer Connectivity framework and notifies its delegate about invitations from nearby peers.

```
class MCNearbyServiceAdvertiser
```

## Overview

Before you can advertise a service, you must create an `MCPeerID` object that identifies your app and the user to nearby devices.

The `serviceType` parameter is a short text string used to describe the app’s networking protocol.  It should be in the same format as a Bonjour service type: 1–15 characters long and valid characters include ASCII lowercase letters, numbers, and the hyphen, containing at least one letter and no adjacent hyphens.  A short name that distinguishes itself from unrelated services is recommended; for example, a text chat app made by ABC company could use the service type `"abc-txtchat"`. For more information about service types, read [Domain Naming Conventions](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/NetServices/Articles/domainnames.html#//apple_ref/doc/uid/TP40002460).

The `discoveryInfo` parameter is a dictionary of string key/value pairs that will be advertised for browsers to see.  The content of `discoveryInfo` will be advertised within Bonjour TXT records, so you should keep the dictionary small for better discovery performance.

For more information about TXT records, read [Bonjour Operations](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/NetServices/Articles/NetServicesArchitecture.html#//apple_ref/doc/uid/20001074).

## Topics

### Configuring and Initialization

[`init(peer:discoveryInfo:serviceType:)`](/documentation/MultipeerConnectivity/MCNearbyServiceAdvertiser/init(peer:discoveryInfo:serviceType:))

Initializes an advertiser object.

[`delegate`](/documentation/MultipeerConnectivity/MCNearbyServiceAdvertiser/delegate)

The delegate object that handles advertising-related events.

[`discoveryInfo`](/documentation/MultipeerConnectivity/MCNearbyServiceAdvertiser/discoveryInfo)

The `info` dictionary passed when this object was initialized.

[`myPeerID`](/documentation/MultipeerConnectivity/MCNearbyServiceAdvertiser/myPeerID)

The local peer ID for this instance.

[`serviceType`](/documentation/MultipeerConnectivity/MCNearbyServiceAdvertiser/serviceType)

The service type that your app is advertising

### Starting and Stopping Advertisement

[`startAdvertisingPeer()`](/documentation/MultipeerConnectivity/MCNearbyServiceAdvertiser/startAdvertisingPeer())

Begins advertising the service provided by a local peer.

[`stopAdvertisingPeer()`](/documentation/MultipeerConnectivity/MCNearbyServiceAdvertiser/stopAdvertisingPeer())

Stops advertising the service provided by a local peer.



---

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)