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.
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:
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
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With