简体   繁体   English

通过蓝牙在iOS和Android之间传输数据?

[英]Transfer data between iOS and Android via Bluetooth?

I've been reading up on how to transfer data between iOS devices over Bluetooth using GameKit. 我一直在阅读如何使用GameKit通过蓝牙在iOS设备之间传输数据。 I'm not writing a game, per se, but do have a need to transfer a small amount of binary data between two devices. 我本身并不是在编写游戏,但确实需要在两个设备之间传输少量二进制数据。 Between two iOS devices, this is easy enough. 在两个iOS设备之间,这很容易。 However, I was wondering if it is possible to transfer data between an iOS device and an Android device via the same mechanism. 但是,我想知道是否可以通过相同的机制在iOS设备和Android设备之间传输数据。

Has anyone come across documentation/tutorial that would explain how to do this? 有没有人遇到过可以解释如何执行此操作的文档/教程? Is it even technically possible? 它在技术上是否可行? Or has Apple put in some sort of restriction that would prevent this? 或者苹果公司是否提出了某种限制措施来防止这种情况发生?

The other option I discovered was Bonjour over Bluetooth. 我发现的另一个选择是Bonjour通过蓝牙。 Would this be a more suitable option for this type of operation? 对于这种类型的操作,这是一个更合适的选择吗?

This question has been asked many times on this site and the definitive answer is: NO, you can't connect an Android phone to an iPhone over Bluetooth , and YES Apple has restrictions that prevent this. 这个问题在本网站上被多次询问,最终的答案是: 不,你不能通过蓝牙将Android手机连接到iPhone ,并且YES Apple有限制可以防止这种情况发生。

Some possible alternatives: 一些可能的选择:

  1. Bonjour over WiFi, as you mentioned. 正如你所提到的,通过WiFi享受Bonjour。 However, I couldn't find a comprehensive tutorial for it. 但是,我找不到一个全面的教程。
  2. Some internet based sync service, like Dropbox, Google Drive, Amazon S3. 一些基于互联网的同步服务,如Dropbox,Google Drive,Amazon S3。 These usually have libraries for several platforms. 这些通常具有多个平台的库。
  3. Direct TCP/IP communication over sockets. 通过套接字进行直接TCP / IP通信。 ( How to write a small (socket) server in iOS ) 如何在iOS中编写小型(套接字)服务器
  4. Bluetooth Low Energy will be possible once the issues on the Android side are solved ( Communicating between iOS and Android with Bluetooth LE ) 一旦解决了Android方面的问题,就可以实现蓝牙低功耗( 通过蓝牙LE在iOS和Android之间进行通信

Coolest alternative : use the Bump API . 最酷的选择 :使用 Bump API It has iOS and Android support and really easy to integrate. 它具有iOS和Android支持,并且非常易于集成。 For small payloads this can be the most convenient solution. 对于小型有效载荷,这可能是最方便的解决方案。

Details on why you can't connect an arbitrary device to the iPhone . 有关无法将任意设备连接到iPhone的详细信息 iOS allows only some bluetooth profiles to be used without the Made For iPhone (MFi) certification ( HPF, A2DP, MAP... ). iOS仅允许使用某些蓝牙配置文件,而无需使用Made For iPhone(MFi)认证( HPF,A2DP,MAP ... )。 The Serial Port Profile that you would require to implement the communication is bound to MFi membership. 实现通信所需的串行端口配置文件绑定到MFi成员资格。 Membership to this program provides you to the MFi authentication module that has to be added to your hardware and takes care of authenticating the device towards the iPhone. 此程序的成员资格为您提供必须添加到您的硬件的MFi身份验证模块 ,并负责向iPhone验证设备。 Android phones don't have this module, so even though the physical connection may be possible to build up, the authentication step will fail. Android手机没有此模块,因此即使可能建立物理连接,身份验证步骤也会失败。 iPhone to iPhone communication is possible as both ends are able to authenticate themselves. iPhone和iPhone之间的通信是可能的,因为两端都能够自我验证。

Maybe a bit delayed, but technologies have evolved since so there is certainly new info around which draws fresh light on the matter... 也许有点延迟,但技术已经发展,因此肯定有新的信息可以为这个问题带来新的亮点......

As iOS has yet to open up an API for WiFi Direct and Multipeer Connectivity is iOS only, I believe the best way to approach this is to use BLE, which is supported by both platforms (some better than others). 由于iOS还没有打开WiFi Direct和Multipeer Connectivity的API,我认为最好的方法是使用BLE,这两个平台都支持(有些比其他平台更好)。

On iOS a device can act both as a BLE Central and BLE Peripheral at the same time, on Android the situation is more complex as not all devices support the BLE Peripheral state. 在iOS上,设备可以同时充当BLE中心和BLE外设,在Android上情况更复杂,因为并非所有设备都支持BLE外设状态。 Also the Android BLE stack is very unstable (to date). 此外,Android BLE堆栈非常不稳定(迄今为止)。

If your use case is feature driven, I would suggest to look at Frameworks and Libraries that can achieve cross platform communication for you, without you needing to build it up from scratch. 如果您的用例是功能驱动的,我建议您查看可以为您实现跨平台通信的框架和库,而无需您从头开始构建它。

For example: http://p2pkit.io or google nearby 例如: http//p2pkit.io或google附近

Disclaimer: I work for Uepaa, developing p2pkit.io for Android and iOS. 免责声明:我为Uepaa工作,为Android和iOS开发p2pkit.io。

You could use p2pkit, or the free solution it was based on: https://github.com/GitGarage . 您可以使用p2pkit,或者基于它的免费解决方案: https//github.com/GitGarage Doesn't work very well, and its a fixer-upper for sure, but its, well, free. 不能很好地工作,它确实是一个固定器,但是,它是免费的。 Works for small amounts of data transfer right now. 适用于现在的少量数据传输。

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

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