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.
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?
- Use iPhone as a game controller in a tvOS app?
- Swift MultipeerConnectivity crash DateComponents unconditionallyBridgeFromObjectiveC
- Maintain a Multipeer Connectivity session in Background via BackgroundTask?
- Disable WiFi from Multi Peer Connectivity
- Peer to peer android and iOS with Wifi direct (multipeer connectivity?)
- iOS Multipeer connectivity framework invitationHandler doesn't seem to accept?
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
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.
- Why UnsafeRawPointer shows different result when function signatures differs in Swift?
- Update UIView class in Interface Builder
- iOS Swift manipulate/parse string
- How can I make a static method in Objective-C?
- Disable select option in IOS Safari
- How to pass data from one view controller to the other SWIFT
- Size of bullets in UITextField with secureTextEntry changes size as focus switches when using custom font
- How to hide uitabbarcontroller
- Using 'stringWithString:' with a literal is redundant
- Is there a quick rule to know when to release Objective-C variables?
- Facebook iOs sdk iphone : Call from multiple viewcontroller
- How can I tell Spotlight to index my .dSYM bundles?
- NSDateComponents weekOfYear returns wrong date
- How do I delete all objects from my persistent store in Core Data?
- How to rotate a flat object around its center in perspective view?