iOS Developer Library

Developer

MultipeerConnectivity Framework Reference MCNearbyServiceAdvertiserDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

MCNearbyServiceAdvertiserDelegate

Inheritance


Not Applicable

Import Statement


Swift

import MultipeerConnectivity

Objective-C

@import MultipeerConnectivity;

Availability


Available in iOS 7.0 and later.

The MCNearbyServiceAdvertiserDelegate protocol describes the methods that the delegate object for an MCNearbyServiceAdvertiser instance can implement for handling events from the MCNearbyServiceAdvertiser class.

  • Called when an invitation to join a session is received from a nearby peer. (required)

    Declaration

    Swift

    func advertiser(_ advertiser: MCNearbyServiceAdvertiser!, didReceiveInvitationFromPeer peerID: MCPeerID!, withContext context: NSData!, invitationHandler invitationHandler: ((Bool, MCSession!) -> Void)!)

    Objective-C

    - (void)advertiser:(MCNearbyServiceAdvertiser *)advertiser didReceiveInvitationFromPeer:(MCPeerID *)peerID withContext:(NSData *)context invitationHandler:(void (^)(BOOL accept, MCSession *session))invitationHandler

    Parameters

    advertiser

    The advertiser object that was invited to join the session.

    peerID

    The peer ID of the nearby peer that invited your app to join the session.

    context

    An arbitrary piece of data received from the nearby peer. This can be used to provide further information to the user about the nature of the invitation.

    invitationHandler

    A block that your code must call to indicate whether the advertiser should accept or decline the invitation, and to provide a session with which to associate the peer that sent the invitation.

    Import Statement

    Objective-C

    @import MultipeerConnectivity;

    Swift

    import MultipeerConnectivity

    Availability

    Available in iOS 7.0 and later.