iOS Development

swift – Peer to Peer connection for iOS units stopped working

To beginning peer to look connection between iOS units;

I used to be utilizing this code;

func setUpSessionForMaster() {
    if advertiser != nil {
        advertiser = nil
    localPeerID = MCPeerID(displayName: peerName )

    if localSession != nil {self.localSession!.disconnect()}
    localSession = MCSession(peer: localPeerID!);
    localSession!.delegate = self;
    browser = MCNearbyServiceBrowser(peer: localPeerID!,
                                      serviceType: serviceName);
    browser!.delegate =  self;

    // begins browser and advetiser for peer to look providers

however following features doesn’t fireplace anymore;

      func browser(_ browser: MCNearbyServiceBrowser, didUpdateState state: MCSessionState) {
print("Browser did replace state: (state.rawValue)")

      func browser(_ browser: MCNearbyServiceBrowser, foundPeer peerID: MCPeerID, withDiscoveryInfo information: [String: String]?) {
print("Browser discovered peer: (peerID.displayName)")

Seems like required permissions has been modified by Apple

I set two setup in information.plist for p2p connection;

1- Bonjour providers
2- Privateness – Native Community Utilization Description


Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button