5

I would like to transfer files between my bluetooth device and iphone. Is there something similar to android.bluetooth.BluetoothSocket on the iOS platform?

Some code samples on connecting to the bluetooth socket will be greatly appreciated.

Piotr Tomasik
  • 9,074
  • 4
  • 44
  • 57
happymeal
  • 1,373
  • 14
  • 24

2 Answers2

3

This article describes 5 ways to set up data exchange over Bluetooth; 2 of them (usage of private API and usage of Ringwald's BTStack on jailbroken devices) won't allow your app to be published on AppStore; one doesn't look to be a real option (MFi licensing). There are 2 options that could be useful:

  1. Using GameKit. This enables your app to have Bluetooth connectivity only with iOS devices. So seems it's not an option for you.

    Tutorial: http://code.tutsplus.com/tutorials/bluetooth-connectivity-with-gamekit--mobile-11610

  2. Using CoreBluetooth. Doesn't limit connectivity to iOS devices only but requires support for Bluetooth Low Energy (BLE) protocol from devices you're going to connect to. I investigated possibility to connect iOS and Android via BLE about year ago and came to conclusion that android devices didn't provide enough BLE support at that time. Maybe something has changed during past year. Please note that BLE doesn't provide a 'socket-like' paradigm, so it may not fit your needs.

    Tutorial: http://code.tutsplus.com/tutorials/ios-7-sdk-core-bluetooth-practical-lesson--mobile-20741

Community
  • 1
  • 1
Nikolay Mamaev
  • 1,474
  • 1
  • 12
  • 21
1

For future visitors, you can open L2CAP channel from your CBPeripheral to have an unrestricted connection to transfer your data. See below for documentation and how to use example source code.

https://developer.apple.com/documentation/corebluetooth/cbperipheral/2880151-openl2capchannel

https://github.com/paulw11/L2CapDemo

Watch this from WWDC2017

Prasad De Zoysa
  • 2,488
  • 2
  • 23
  • 30
  • The L2CAP stuff is mentioned in the WWDC2017 video starting at time 14:50 - thought it would be useful for others (would like to have edited, but the queue is full) – alex gimenez Jan 24 '22 at 08:03