MultipeerConnectivity does not work as expected on iOS 14
Asked Answered
J

2

5

When the MCBrowserViewController is invoked

-[MCBrowserViewController advertiser:didNotStartAdvertisingPeer:]: unrecognized selector sent to instance

error message is thrown.

when MCAdvertiserAssistant tries starts advertising

-[MCAdvertiserAssistant advertiser:didNotStartAdvertisingPeer:]: unrecognized selector sent to instance

error message is thrown.

Struck and unable to proceed. My business depends on MultipeerConnectivity framework.

Any help will be greatly appreciated.

Joannejoannes answered 24/9, 2020 at 6:23 Comment(0)
H
8
let assistant = MCAdvertiserAssistant(serviceType: "tictactoe", discoveryInfo: nil, session: session)
let browser = MCBrowserViewController(serviceType: "tictactoe", session: session)

Insert in the info.plist the following fields:

  1. Privacy - Local Network Usage Description
  2. Bonjour services with the following initialisation: _tictactoe._tcp and _tictactoe._udp

enter image description here enter image description here

Hygrometry answered 26/9, 2020 at 9:46 Comment(11)
What are these value actually?_tictactoe._tcp and _tictactoe._udpJoannejoannes
Thanks for your answer actually this solution does not solve the issue. Btw the issue is not happening in Simulator.Joannejoannes
Those are the identifiers you are using while creating the advertiser and browser.Hygrometry
What value should i use ?Joannejoannes
How do you create your MCBrowserViewController and MCAdvertiserAssistant? Can you show your code?Hygrometry
advertiser = MCAdvertiserAssistant(serviceType: identifier, discoveryInfo: nil, session: session) browserController = MCBrowserViewController(serviceType: identifier, session: session)Joannejoannes
What is the value of the identifier variable?Hygrometry
both are same "PARTY_ID"Joannejoannes
so you should add as _PARTY_ID._tcp and _PARTY_ID._udpHygrometry
Crash got fixed but the connection gets declined now. you got any idea?Joannejoannes
I am unable to see Hosted Device while Joining session. Please help guysColonist
C
2

i did face some issues implementing MultipeerConnectivity too. After some research found a fix.. what i did was

  1. i followed https://www.hackingwithswift.com/example-code/networking/how-to-create-a-peer-to-peer-network-using-the-multipeer-connectivity-framework this.
  2. added Bonjour services (value- _*serviceType*._tcp) and Privacy - Local Network Usage Description in Info.plist.
  3. removed SceneDelegate related stuff as in Opt out of UISceneDelegate/SwiftUI on iOS

clean and build.

Note:i am working with Xcode12 and iOS14.

Cunaxa answered 1/10, 2020 at 11:8 Comment(1)
Crash got fixed but the connection gets declined now. you got any idea?Joannejoannes

© 2022 - 2024 — McMap. All rights reserved.