Multipeer connectivity over Bluetooth?

混江龙づ霸主 提交于 2019-12-10 19:24:22

问题


I started to advertise, started to browse. When on the same WiFi, it works.

But when I turn WiFi off, and leaving only Bluetooth, nor even the -(void)browser:(MCNearbyServiceBrowser*) browser foundPeer:(MCPeerID*) peerID withDiscoveryInfo:(NSDictionary*) info gets called.

Do I have to indicate to advertise on Bluetooth explicitly somehow? Or should it work this way seamlessly?

With GameKit there was a setting for this. I can't find any similar in MC.


回答1:


The same code will work.

No need to explicitly advertise on Bluetooth. It will automatically come. Just take care of keeping bluetooth of both devices ON.

There is no explicit setting for bluetooth or Wifi, It will connect devices in whatever possible way they are available.




回答2:


Oh, it was discoveryInfo. I was included it just before trying the setup over Bluetooth.

But as it turned out, this discoveryInfo dictionary have plenty of exceptional rules. See initWithPeer:discoveryInfo:serviceType:

// This won't work without a single line of warnings or errors (!).
info = @{ @"myID" : @(102) };

// This will work.
info = @{ @"myID" : @"102" };


来源:https://stackoverflow.com/questions/21936645/multipeer-connectivity-over-bluetooth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!