Arseniy Panfilov
Arseniy Panfilov

Reputation: 361

discover another ios device without connecting to common network

I was looking into Multipeer Connectivity Framework trying to find a way of how to connect nearby devices. To be more precise I have two iPhones at my disposal. The idea is to establish connection between them in order to be able to transfer small audio streams. One-to-one connection is enough, there's no need to create groups.

It all works fine and devices can discover each other if I do any of following:

But is it possible to somehow discover nearby devices only by having them both wi-fi turned on? Ideally they would "see" each other and create a direct connection.

I'm sorry if question like this was already asked, but it's really hard to formulate what I try to achieve in a sentence and therefore it's not easy to find any info about it.

Upvotes: 1

Views: 266

Answers (2)

Arseniy Panfilov
Arseniy Panfilov

Reputation: 361

Turned out that just using Bounjour API (NSNetService level) makes it really easy:

let browser = NSNetServiceBrowser()
browser.includesPeerToPeer = true

Ended up taking this excellent example from Apple, rewriting parts of it in swift and adapting it to my needs.

Note: I've also tried to make it work with MultipeerConnectivity framework, but it just didn't work. Although devices would discover each other successfully they still couldn't establish a connection. And NSNetService-based solution works just fine.

Upvotes: 2

xujiangtao
xujiangtao

Reputation: 1

if you only need to send some audio or video files to another apple device, I think you can use airDrop to to this.

Upvotes: 0

Related Questions