简体   繁体   English

iOS设备之间的对等通信

[英]Peer-to-peer communication between iOS devices

I am trying to prototype a solution to a problem and am currently exploring multiple routes I could try. 我正在尝试制定解决问题的原型,目前正在探索可以尝试的多种路线。 Is it possible for one iOS device, running a certain app, to communicate directly with another iOS device, running the same application - without the need to be on the same LAN? 一个运行特定应用程序的iOS设备是否可以与另一个运行相同应用程序的iOS设备直接通信-无需位于同一LAN上?

Solutions I am currently investigating are using Bluetooth and ad-hoc wireless connections. 我目前正在研究的解决方案正在使用蓝牙和临时无线连接。

Ideally, the application when installed would ask the user for the required permissions, and then would accept and/or send data to/from another client after a handshake had happened. 理想情况下,应用程序在安装时会向用户询问所需的权限,然后在发生握手后将其接收数据和/或从另一个客户端发送数据。

My concern with Bluetooth is that 'pairing' would need to happen with every device, rather than happen in the background once the user has installed the app. 我对蓝牙的担心是,“配对”将需要在每台设备上进行,而不是在用户安装应用后在后台进行。 I have a feeling what I am talking about isn't possible from what I've been reading elsewhere on Stackoverflow. 从我在Stackoverflow上其他地方所读到的内容中,我觉得我所说的是不可能的。

Take a look at Bluetooth Low Energy. 看看低功耗蓝牙。

https://developer.apple.com/library/ios/#samplecode/BTLE_Transfer/Introduction/Intro.html#//apple_ref/doc/uid/DTS40012927 https://developer.apple.com/library/ios/#samplecode/BTLE_Transfer/Introduction/Intro.html#//apple_ref/doc/uid/DTS40012927

Here is another example, 这是另一个例子

https://github.com/KhaosT/CBPeripheralManager-Demo https://github.com/KhaosT/CBPeripheralManager-Demo

You might also want to look into GameKit and peer-to-peer connectivity there. 您可能还想研究GameKit和那里的对等连接。

I can't tell you anything about it, but you might try looking at iOS 7. If that's an option, I'd take a look. 我什么都没告诉您,但是您可以尝试查看iOS7。如果可以的话,我来看一下。 Can't talk about what it is because of NDA though. 但是,由于NDA,无法谈论它是什么。

Depending on what you need to communicate, you could try checking out this project, which lets you share arrays of strings between iOS devices over Bluetooth LE. 根据您需要交流的内容,您可以尝试签出该项目,该项目使您可以通过Bluetooth LE在iOS设备之间共享字符串数组。

You don't need to "pair" the devices and it can still communicate while the app is in the background. 您无需“配对”设备,并且当应用程序处于后台时,设备仍然可以通信。 SimpleShare 简单分享

Hope it helps! 希望能帮助到你!

From the documentation of MultipeerGroupChat: MultipeerGroupChat sample application utilizes the Multipeer Connectivity framework to enable nearby users to discover, connected, and send data between each other. 从MultipeerGroupChat的文档中:MultipeerGroupChat示例应用程序利用Multipeer Connectivity框架使附近的用户能够发现,连接和发送彼此之间的数据。 This sample simulates a simple chat interface where up to 8 devices can connect with each other and send text messages or images to each other. 此示例模拟一个简单的聊天界面,其中最多8个设备可以相互连接,并彼此发送文本消息或图像。 Here you will learn how to bring up framework UI for discovery and connections and also how to monitor session state, listen for incoming data and resources, and send data and resources. 在这里,您将学习如何启动用于发现和连接的框架UI,以及如何监视会话状态,侦听传入的数据和资源以及发送数据和资源。

This is an excellent example at developer.apple.com here is the link https://developer.apple.com/library/ios/samplecode/MultipeerGroupChat/Introduction/Intro.html 这是developer.apple.com上的一个很好的例子,这里是链接https://developer.apple.com/library/ios/samplecode/MultipeerGroupChat/Introduction/Intro.html

Also this tutorial from Ralf Ebert demonstrates how to use Multipeer Connectivity framework for peer communication should help you. Ralf Ebert的本教程还演示了如何使用Multipeer Connectivity框架进行对等通信,这将为您提供帮助。 https://www.ralfebert.de/tutorials/ios-swift-multipeer-connectivity/ https://www.ralfebert.de/tutorials/ios-swift-multipeer-connectivity/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM