Is it possible, in principle, for an Android device to interface with an iPhone over Bluetooth/GameKit? - iphone

(I am not interested in pure theory, but as a practical near or mid-term possibility, say within 12-24 months.)
As a developer familiar with (but not specializing in) two major smartphone platforms, should I expect an Android library to come out which can spoof itself onto an iPhone app's GameKit-based network. It seems reasonable that a Bluetooth interface between platforms might square the opportunity to make useful applications, in the same way that modems benefited PC/Mac platforms via Metcalfe's Law.
I am looking for one of two answers:
Is this obviously not likely (e.g. because of encryption)? If so, what is the reason? Is it possible in principle, but requiring years of reverse-engineering (like SMB/CIFS/Samba)? Or is it a no-brainer and just a matter of time? Please give evidence supporting your reason.
Is there an alternative way to have direct peer-to-peer networking besides GameKit? For example, a hand-rolled network using Bluetooth or ad-hoc WiFi? It would be nice to spoof an Android device into an existing iPhone app but my main question is, can the devices speak with each other at all!

Yes, it is possible. GameKit is a protocol using TCP and/or UDP over a BNEP Bluetooth connection. It also uses a trick to identify other iOS devices using the Extended Inquiry mechanism in Bluetooth 2.1+.
I was able to simulate the EIR responses, now, someone needs to reverse engineer the GameKit protocol. This doesn't need Bluetooth, as it is also used for GameKit connections over WLAN.
If anybody can re-implment GameKit for WLAN connections, I can finish the Bluetooth version.

No, and it wont come soon or even at all... Apple pride themselves with their security features, and bluetooth connections can access private data. There will probably not be any cross platform bluetooth framework until something is agreed upon by both companies.
Bump as said by a previous answerer uses a remote server, and the data transferred is not via BT.

GameKit is Bonjour so a Bonjour (which is on IP) over Bluetooth on Android should work.

That should be possible as Bluetooth is capable of setting up tcp/ip networks. Though I have no knowledge of the IPhone SDK whatsoever, but Android does have a BluetoothSocket and BluetoothServerSocket for TCP connections.

This article, http://blog.moritzhaarmann.de/blog/2014/04/27/sorry-state-of-p2p/ written in 2014, suggest it is possible via Bluetooth LE. Available in Android 4.3+ and iOS6+
Two issues:
According to the Android Dashboard only around 30 percent of Android devices support Bluetooth LE https://developer.android.com/about/dashboards/index.html?utm_source=ausdroid.net
Communication between Android-to-Android must be done using some other method (which is not a big problem) because Android devices cannot act as server for B LE connections.

Bounjour on the iPhone gives you full access to all of the Bluetooth protocols, so you don't have to use GameKit. As for when someone will provide an easy to use iPhone to Android GameKit like framework - hard to tell.
An iPhone can already talk to any other Bluetooth device using Bonjour today.
-t

It is absolutely possible! In fact I am amazed that more people haven't done it!
Theory:
Bluetooth is just a wireless socket that you push data across and it comes across the other side, just like tcp/ip.
Practice:
http://www.techcrunch.com/2009/11/11/bump-goes-cross-platform-with-new-android-app-upgrades-iphone-version-too/
Better yet, Bump is cross-platform, which means that you can bump an Android phone with an iPhone and it should work seamlessly.

Related

iPhone Bluetooth Communication Examples

I've been trying to find examples on communicating with bluetooth devices on iOS and have been coming up short. As I understand it SPP is not yet supported. At the simplest level, I'd like to send a simple 1 or 0 signal to the bluetooth device I'm creating. (It's a bluetooth switch that would turn something on and off). Is there a way to cleverly do this through the HID or HFP profiles?
The short answer to your question is that you can't connect to an arbitrary Bluetooth device you may happen to have, you can only connect to a Bluetooth device that has come through Apple's licensing program (i.e. the "Made for iPod/iPhone" label). From Apple's documentation:
Q: [The External Accessory framework allows] my application to communicate with Bluetooth devices. So why doesn't my application see the Bluetooth accessory sitting next to my iPhone?
A: The External Accessory framework is designed to allow iOS applications to communicate only with hardware accessories that are developed under Apple's MFi licensee program.
So there is no public API for accessing an arbitrary Bluetooth device from within iOS: you have to go through the External Accessory Framework to communicate via Bluetooth, and the EAF's mission is "communicate with MFi devices," not "communicate with arbitrary external devices." A sufficiently ingenious developer could probably hack something in there, but -
it's a non-trivial undertaking
you are spectacularly unlikely to get past the App Store approval process
So there's just not much percentage in it - the effort of doing so is unlikely to reward you.
If there already exists an MFi device that can be coerced into doing something that you want, that's probably your best chance - short of going through the MFi approval/licensing process yourself, of course. If you want to do so, have at it and good luck.
I'm answering this question late because Zeroxide's answer is incorrect (you can use a random Bluetooth keyboard with your iOS device because Apple implemented that connection, which is different from giving you a public API path to doing likewise) and I find Rokridi's answer to be incomplete-though-headed-in-the-right-direction.
Edit: A caveat has since been added to the linked Apple page about Bluetooth Low-Energy devices. So there's a loophole, but it's not a big one because very, very few Bluetooth LE devices have actually been produced as yet.
As far as i know, if your external device is non iOs device then you should use External Accessory Framework to communicate your application with it. Threfore, you external device should be certified by Apple through the Made for Ipod program (MFI). Hope this helps.
If you want to use classic Bluetooth (not BLE), then you have to first PAIR the iOS device to the Bluetooth device (in Settings). If you can't do that then you can't communicate with it with your app.
NO. whether device is MFi certified or not, you can connect device to iphone if bluetooth profile is HFP, or HID's (ordinary profiles. not iAP profile). Think about bluetooth headset or keyboard. does it need MFi mark on it to use? NO. Never.

iPhone bluetooth

Is it possible to identify devices around me that have their bluetouth enabled?
I don't need to communicate with them, just know they are there.
I am looking for something similar to android's BluetouthDevice.startDiscovery()
Is something like this possible?
Apple turns out to be very restrictive about Bluetooth communications for iOS platform.
Focusing about a native application with Xcode (but not PhoneGap based - PhoneGap is a Xcode plugin that allows web apps to be converted into native ones; btw it gives a quite nice but limited access to underlying hardware resources) for a iOS device to communicate with bluetooth devices (even with discovery actions) the following conditions have to be met:
-) The device you're trying to discover must be equipped with Apple Bluetooth authentication chip (you can ask to Apple directly for the MFi program);
-) Internally your app must declare a protocol name (e.g.: net.yourcompany.proto0) which the devices you connect with must conform to;
-) You must use Apple's External Accessory Framework to establish communication with such devices.
In short, by this procedure Apple guarantees that the only Bluetooth communications an iOS device can establish are just with authorized and certified Bluetooth devices.
I've gone 400 Mph about this thing but I hope it can give you some pointer to start your search.
The topic is too wide to be treated here in its full length.
One thing you might want to look into is Bonjour and NSNetServiceBrowser.
You can publish a service and also search for other services around you. There are ways to run Bonjour in the background (http://stackoverflow.com/questions/6345554/bonjour-in-the-background).
The only limitation with this approach is that everyone else would also need to be running the app as well. Also, by default Bonjour discovers over both WiFi and Bluetooth, something else you would probably need to look into.

How to do peer-to-peer communication in an iPhone app?

I'm trying to write a simple chat application for the iPhone (as an experiment). Is there a simple way for two devices to discover each others' IP addresses, and given the addresses is there a simple API or protocol that would let me send text messages back and forth?
I've investigated SIP (specifically Sofia and eXosip), but these tools exist as C libraries and are beyond my current ability to port them to the iPhone.
Update: I'm trying to connect two devices over the Internet (i.e. not over Bluetooth or a local wireless network, which is what GameKit does).
You're going to need a server that provides the match making service. Game Center makes this pretty easy, but your users will have to have Game Center accounts.
Alternatively, you can set up an XMPP (formerly Jabber, it's what powers Google Chat) server (I've never done this, but there are several available) and use the XMPP Framework for Cocoa. There are instructions for using it in iPhone apps here.
I'm sure there are other chat servers and client source also available. IRC and Mobile Colloquy come to mind.
Finally, you could write your own server using your favorite server language / framework. This isn't too hard (I've done it myself), but it's far from what I'd call simple, and I wouldn't use it for a production system.
There is support for exactly this kind of ad-hoc peer-to-peer networking in GameKit. Have a look at the second half of the GameKit documentation for details:
http://developer.apple.com/library/ios/#documentation/...
NSNetService is a good option.
Take a look at WebRTC Datachannels. WebRTC is a newer option with native iOS support a standard that is still being finalized, but it is more flexible should the iOS app need to communicate with browser or even android peers

How can I send simple data from an iPhone to another iPhone, or an Android?

I'm just getting started with mobile development, and after considerable searching I'm still confused about sending a message from my iPhone to another or an Android. For instance, in building a simple Tic-Tac-Toe game, if I want to notify the other phone of a move, what is the best way to do so? Wifi, bluetooth, 3G? And how?
Many methods seem to point to communicating through a web server, but I'd rather send them directly from phone to phone if possible. (this is for native apps of course)
If you don't want to have a server (or even if you do! It depends!) it sounds like you will want to use TCP sockets. Apple doesn't have a generic bluetooth API to use with iPhone-to-android communication and you'll have TCP access anyway with 3G. A 3G network connection is very similar to wifi and you should be able to check for the difference as needed with little change to your overall networking code. I'm not sure if bonjour is supported on android, but I bet someone has ported it for similar reasons already, and it is supported in iOS. Apple has a networking section for iOS that you may find informative.
Additionally if you want to stay within the iOS device only realm you could use GameKit to communicate via bluetooth.
Hope that helps some.
The easiest way is to create a web server with an API and the clients poll the server for new moves (or the server pushes the client an update). This is the only way you're going to be able to do it over 3G unless you can figure out the IP addresses of both phones (do phones even keep the same IP address for a long period of time?) and open up sockets between them and let one phone be the server and the other be the client (could cause potential cheating).
WiFi is not always there - by limiting your users' options to areas with access points, you'll lose sales. Not sure about Bluetooth - how prevalent is it on handsets, how much of the API is exposed. Your best bet, IMHO, is 3G. With some kind of a central presence server (Web or otherwise), with optional proxying. Read up on peer-to-peer networking.
As far as i know does the iphone only support incoming messages over push notifications.
This means, that you have to update the information, by requesting it from web services etc.
The bluetooth API of the iphone doesn't support this either.

iPhone Gamekit peer with a desktop peer

I am looking for a way to establish a wireless connection between an iPhone and a desktop client. Gamekit looks promising but all the examples / documentation only explain iPhone to iPhone.
Are there examples / documentation for an Gamekit peer on the desktop (cocoa or java)?
What are the alternatives without doing to much low level socket programming?
The iPhone emulator does not run these bluetooth p2p connections. Hence, it can only be tested with real hardware.
It is a little confusing because the GKSession reference talks only about being a way to connect peers over bluetooth, while the GKPeerPickerController states "can be configured to select between Bluetooth and Internet connections." However there's a clear note there that they're not really going to help you with internet based connections.
This is unfortunately a non-answer, but...
GameKit is an abstraction of the bluetooth and wifi networking layers, allowing a specific set of protocols for communication between two devices -- to communicate with a desktop client, you would need to replicate all of the GameKit functionality on the desktop, since there is no comparable API on the desktop. This would not be a simple undertaking.
I would highly suggest developing something over bonjour, as #Jordan suggested. Bill Dudney's project (blog article). It's a great place to start.
Citing Game Kit Framework Reference's Features paragraph:
Peer-to-peer connectivity allows your game to create an ad hoc Bluetooth or wireless network between multiple iPhones in the same local area. Although designed with games in mind, this network is useful for any type of data exchange among users of your app. For example, an app could use peer-to-peer connectivity to share electronic business cards or other data. This functionality is only available on iOS. You can also get the same functionality using Game Center.