I am creating an iOS / macOS application that uses remote control features through the Multiber Connectivity Framework. Since the device that will be monitored and controlled remotely will work for a long period of time, it is impractical to use automatic control methods, since the monitoring device can be blocked or put into sleep mode, and then disconnect the connection. Therefore, I use a programmatic approach, so when the monitoring devices lose their connection, they automatically connect when they unlock / wake up, and the application starts again. My connection works fine using the ViewController method, but not the delegate subroutine approach. Advertising, viewing and invitation work fine, but when the invitation is accepted from the remote side, I get a few errors and a failed connection. What is strange is that some errors are GCKSession errors.
So why is he trying to use the GameCenter system? And why does he fail after accepting the invitation? Could this be a bug in the Xcode 8 / Swift 3 / iOS 10 / macOS Sierra Beta SDK?
[ViceroyTrace] [ICE][ERROR] ICEStopConnectivityCheck() found no ICE check with call id (2008493930) [GCKSession] Wrong connection data. Participant ID from remote connection data = 6FBBAE66, local participant ID = 3A4C626C [MCSession] GCKSessionEstablishConnection failed (FFFFFFFF801A0020) Peer Changing Failed [GCKSession] Not in connected state, so giving up for participant [77B72F6A] on channel [0]
Here is the code from my connection class
func startAdvertisingWithoutUI () { if advertiserService == nil { advertiserService = MCNearbyServiceAdvertiser (peer: LMConnectivity.peerID, discoveryInfo: nil, serviceType: "mlm-timers") advertiserService?.delegate = self session.delegate = self } advertiserService?.startAdvertisingPeer() } func browserForNearbyDevices () { if browserService == nil { browserService = MCNearbyServiceBrowser (peer: LMConnectivity.peerID, serviceType: "mlm-timers") browserService?.delegate = self session.delegate = self } browserService?.startBrowsingForPeers() } func sendInvitation(to peer: MCPeerID) { browserService?.invitePeer(peer, to: session, withContext: nil, timeout: 60) } func advertiser(_ advertiser: MCNearbyServiceAdvertiser, didReceiveInvitationFromPeer peerID: MCPeerID, withContext context: Data?, invitationHandler: (Bool, MCSession?) -> Void) { let trustedNames = GetPreferences.trustedRemoteDevices for name in trustedNames { if name == peerID.displayName { invitationHandler(true,session) return } } invitationHandler (false, session) }
source share