Instance Method

advertiser(_:didReceiveInvitationFromPeer:withContext:invitationHandler:)

Called when an invitation to join a session is received from a nearby peer.

Required.

Declaration

func advertiser(_ advertiser: MCNearbyServiceAdvertiser, didReceiveInvitationFromPeer peerID: MCPeerID, withContext context: Data?, invitationHandler: @escaping (Bool, MCSession?) -> Void)

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.