1 MCNearbyServiceAdvertiser
2 MCNearbyServiceAdvertiserDelegate
MCNearbyServiceAdvertiser通知附近的设备发出邀请。这个类会有回调,告知有用户要与您的设备连接,然后可以自定义提示框,以及自定义连接处理。
/// 初始化MCNearbyServiceAdvertiser
public init(peer myPeerID: MCPeerID, discoveryInfo info: [String : String]?, serviceType: String)
/// MCNearbyServiceAdvertiserDelegate代理
weak public var delegate: MCNearbyServiceAdvertiserDelegate?
/// 当前MCPeerID
public var myPeerID: MCPeerID { get }
/// 携带信息
public var discoveryInfo: [String : String]? { get }
/// service类型
public var serviceType: String { get }
/// 发出广播
public func startAdvertisingPeer()
/// 结束广播
public func stopAdvertisingPeer()
/// 广播未运行的错误
@available(iOS 7.0, *)
optional public func advertiser(advertiser: MCNearbyServiceAdvertiser, didNotStartAdvertisingPeer error: NSError)
/// 附近的设备发出连接请求
@available(iOS 7.0, *)
public func advertiser(advertiser: MCNearbyServiceAdvertiser, didReceiveInvitationFromPeer peerID: MCPeerID, withContext context: NSData?, invitationHandler: (Bool, MCSession) -> Void)
Swift
Multipeer Connectivity Framework Reference
MCNearbyServiceAdvertiser Class Reference
MCNearbyServiceAdvertiserDelegate Protocol Reference
时间 | 描述 |
---|---|
2016-01-22 | 博文完成 |
CSDN:http://blog.csdn.net/y550918116j
GitHub:https://github.com/937447974/Blog