Bluetooth/WiFi between Mac app and iOS app
How can I make a Bluetooth Mac app that connects with an iOS app and sends messages ?
Or an iOS app that connects with a Mac app via a local WiFi network ?
- What does this mean? “'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X”
- Xcode - free to clear devices folder?
- Is it possible to develop iPhone apps with a Hackintosh?
- Is it possible to get the 'live' current location with an iOS Simulator?
- What is the equivalent for java interfaces or objective c protocols in swift?
- How to check for an active Internet connection on iOS or OSX?
Solutions Collect From Internet About “Bluetooth/WiFi between Mac app and iOS app”
NOTE: this answer is now outdated as with the introduction of CoreBluetooth (Bluetooth LE v4) since iOS6 and OSX 10.7 any iOS device is open to any kind of communication with any other BLE compatible device, either a Mac or PC or external hardware.
The answer below is still valid if you cannot support BLE, due to old hw or specific requirements (e.g. required bandwidth)
As far as I know, this is almost impossible. Bluetooth connection between iOS devices is well supported with the GameKit framework but there is no support for connection with other OSes, OSX included. The only connection between Mac and iPHone I have ever seen is with the hotspot feature (when it works).
Consider for example the Keynote Remote app. This app allows you to control a Keynote presentation using your iPhone as a remote. It allows this control when the two devices are Keynote-paired on the WiFi, but this connection is not allowed using Bluetooth, while with Bluetooth you can control a Keynote presentation between two iOS devices. And you can find this statement in Apple tech note 2152:
An important consequence of the first point is that Bluetooth peer-to-peer networking can only be used to communicate between iOS devices; you can't use it, for example, to communicate between an iOS device and a computer running Mac OS X.
As far as the WiFi question (I forgot to reply to it in my first question) essentially you to kind of problems to solve: discoverability and data transfer. In order to determine if two devices are in the same network, you can use the Bonjour protocol. Essentially one of the machines publish itself as service-provider for a specific service (you can create your own service: e.g. “_mytype._myprotocol”) and the would-be client will search for a server. Besides Bonjour takes care of other things like addressing and DNS without the two apps to know the details of the local network they are in. This is explained in Apple docs here: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/NetServices/Articles/about.html
Note that Bonjour is at the base of features like AirPlay (Apple TV), AirPrint and probably also AirDrop but it is supported by a lot of devices, e.g. some NAS. In the SampleCodes section of the Apple developers site you will find a great example, called “BonjourWeb” that shows how service discovery works. You can easily try it in your iPhone simulator or device and if you have some Bonjour-enabled device you will see it in the list.
The second problem of course is then real data communication between the two devices, is up to you to define a custom client/server or use a standard web-server based approach. This depends on the application and the data flow. The first approach is better as it is highly customized, you must study the NetworkStreams concepts and check out the SimpleNetworkStreams code in the apple library (this is a simple communication app between a Mac and an iPhone; not always working but it is a good starting point)
- Sorting an NSArray by a key-value relationship that is 2 levels deep
- Keyboard Extension Crash on Device
- How is a return value of AnyObject! different from AnyObject
- What is the difference between setting object = nil and VS and object = nil?
- Cannot open/create SQLite database in iOS
- Make an UIImage from a CMSampleBuffer
- Can someone explain the CALayer contentsRect property's coordinate system to me?
- Transitioning to landscape rotation within a uinavigationcontroller
- NSTextCheckingResult for phone numbers
- What is the best way to make a UIButton checkbox?
- Swipe to Delete and the “More” button (like in Mail app on iOS 7)
- For loop for Dictionary don't follow it's order in Swift
- UIScrollview Autolayout Issue
- Core-Data iPhone: could not locate an NSManagedObjectModel
- NSMutableArray – Remove duplicates