IOS7 Multipeer Connectivity Creating custom nearby browser list using advertiser's discovery Info

I’m using Multipeer Connectivity Framework in IOS7 to make a chatting application. And I’m using the built-in MCBrowserViewController to display a list of nearby peers.

I’d like to include the advertiser’s profile info in the nearby peer list. So that browsers see a list that contains and image and some data about the nearby peers.

  • Multipeer Connectivity crash when inviting peer that stopped advertising
  • Connect Browser & Advertiser without showing alert message in Multipeer connectivity
  • Multipeer Connectivity audio streaming stop work on background
  • Disable WiFi from Multi Peer Connectivity
  • Convert any Data Type into NSData and back again
  • Swift MultipeerConnectivity crash DateComponents unconditionallyBridgeFromObjectiveC
  • I think it can be accomplished by passing data through discoveryInfo when the advertiser is initialized. I pass the discoveryInfo data in like this:

    // create Discovery Info
    NSArray *objects=[[NSArray alloc] initWithObjects:@"datguy",@"28", nil];
    NSArray *keys = [[NSArray alloc] initWithObjects:@"Name",@"Age", nil];
    self.dictionaryInfo = [[NSDictionary alloc] initWithObjects:objects forKeys:keys];
    
    //  Setup Advertiser
    self.advertiser = [[MCAdvertiserAssistant alloc] initWithServiceType:@"txt_msg_service" discoveryInfo:self.dictionaryInfo session:self.advertiseSession];
    [self.advertiser start];
    

    But is there any way to create a custom MCBrowserViewController that displays the discoveryInfo on the other end rather than using the built in one? Does anyone have any example code?

    Solutions Collect From Internet About “IOS7 Multipeer Connectivity Creating custom nearby browser list using advertiser's discovery Info”

    I suggest creating your own tableView to display the list of nearby devices from your MCBrowser.

    I am creating a wrapper with convenient methods so that you can populate the nearby devices much more easily. https://github.com/thkien/THMultipeer

    First set your discovery info as you want before you start broadcasting (this is including advertising
    and browsing):

    THMultipeer.me().serviceType = "thkeen-test"
    THMultipeer.me().info = ["model": UIDevice.currentDevice().model]
    THMultipeer.me().broadcast()
    

    Now you have full control of how you want to populate the UI. All you need to do is implement the delegate in your view controller:

    - (void)multipeerNewPeerFound:(MCPeerID*)peerID withName:(NSString*)name andInfo:(NSDictionary*)info atIndex:(NSInteger)index;
    - (void)multipeerPeerLost:(MCPeerID*)peerID atIndex:(NSInteger)index;
    - (void)multipeerAllPeersRemoved;
    

    If you want to get the whole list of peers, simply call: THMultipeer.me().peers (Swift language)

    Everything is already handled by the library. Yet the part I have not done is the custom MCSession, I’m only done with the Discovery part. Hope I can finish it in 2 – 4 weeks. The library is in Objective-C so it should be backward compatible.