swift – Peer to Peer connection for iOS devices stopped working


To starting peer to peer connection between iOS devices;

I was using 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;

    
    // starts browser and advetiser for peer to peer services
    browser!.startBrowsingForPeers()
    
    
}

but following functions does not fire anymore;

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

      func browser(_ browser: MCNearbyServiceBrowser, foundPeer peerID: MCPeerID, withDiscoveryInfo info: [String: String]?) {
print("Browser found peer: \(peerID.displayName)")
      }
 

Feels like required permissions has been changed by Apple

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

1- Bonjour services
appName.upd
appName.tcp
2- Privacy – Local Network Usage Description

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img