communication between smartphone - iphone

how can I communicate with another smartphone per example in a game?
I'm developing in objective-c, I need to pass/receive informations about positions of some elements on the screen, but I've not ideas of how i can do this, can you give me some tips? Do i need a physical server with a socket open? and how can i manage the connection?
Thanks for any help.
Jonathan.

Look into the peer-to-peer methods of GameKit. It's designed for multiple devices to communicate with each other. iOS only.

One phone can't readily programmatically talk directly to another phone. Well, you might be able to get phone A to send an email or SMS to phone B, but then phone B's app won't be able to act on the notification. (Since you mention obj-C I assume you're using iOS)
So you'll likely have to have a central server help out. Assuming apps running on both phones. Phone A can make an http request to the server; while phone B polls for a possible response. It can use a comet-like technique to reduce polling overhead.

Related

Share text between iPhone and other phones using wifi

Is it possible to send and receive data between iPhone and other phones such as blackberry or android over wifi. I am on the move it to create an iPhone app with the above functionality. Can any one has previous experience in this, or any sample codes to do this. I have searched a lot but couldn't find anything relevant.
you can do this by using a server application. So the iphone pushes the data to the server and the other devices are either getting push notifications or something similar or simply poll for the data.
Without a server, you have the trouble of finding the other devices. If its safe to assume they are all on the same subnet, then you could use a UDP broadcast to do this.
There's many ways of doing this, every one with its own pitfalls. So there's no generic answer to this question without knowing in more detail what's the purpose of it.

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 app communication without using webservices

I want to send some Text plus a image from one iphone application to other iphone app but restriction is I should not use a web server in between communication,Is there any way to fulfill it ?
Details: There are two independent devices and could be far enough say out of network. My requirement one app adds some text with a image and sends it to another iphone which can be at any long distance , and the app installed in another iphone will read that info and image into itself.
Actually there is a solution that meets your needs — and that fits to bbums answer:
Create a HTTP-Server on the iPhone, using cocoahttpserver. than you will ask some webservice like whatismyip.com for your public ip. with this your iPhone can be connected worldwide.
But very likely ur wifi-network is not forwarding your port to the iPhone. Ash.
And even if: Now it gets difficult. How to publish your ip from one phone to the other? hmmm... — I got it: I will exchange the information in a centralized space! In the web!
... wait — that would be a Webserver.
You see: Without any kind of server in the Web the users would need to exchange ip manually and have full admin power and knowledge about the local network.
So IMHO bbums answer is the only way to go.
PS: I am working with http server running on iPhones. In local network that works great, especially with bonjour. And you can use them over distance network — but only with reconfiguration of your router — something you shouldn't force your user to do
There is far from enough information to provide a specific answer.
two apps on two different devices?
are the two devices on the same network?
are the two devices both on WiFi?
do you need the user to receive a notification or something if the app isn't running?
If on same device, you can define a custom URL handler in the destination app and then openURL: in the source app to pass the data over. Encode your image and text into the URL, but be careful of size limitations.
If on different devices, there are many possible solutions, but answering the above questions will be critical to actually knowing what solution is appropriate.
Given your comment -- two apps, different devices, arbitrary networks -- then you are going to have to have some kind of server in between. Note that the recently added Game Center does have the ability to rendezvous two users, but it has a very particular user experience that may not be appropriate to your needs.
I would suggest that you investigate using push notifications to notify the receiving user of the availability of content. As for moving the content between, no direct connection is possible and you will have to have some kind of store-and-forward server in between. And, yes, a web server is going to be the easiest possible solution simply because HTTP is ubiquitous these days.
If there's no network of any kind available, but both parties have amateur radio licenses, then hooking the two devices up to HF packet radios might work.
THIS is super EASY.
I would code up some software that can turn data into modem signal, like the good old dial up modem. The device would actually make those annoying buzzing sounds.
You get the phone number for your friends nearest landline and call him.
He places his iPhone near the phones receiver in listen mode and you connect to his phone using your audible modem.
Bingo, via the power of sounds you have sent data which is decoded on his device and all for the very cheap price of a phone call, there are pretty cheap these days especially if you use Skype.
Easy Way (relatively speaking)
A way two apps on different networks can communicate without setting up a web server of some sort is as follows.
Use an existing third party storage system like DropBox.
Each app would need the login and password for your DropBox. Then both apps can read and write files that the other app can see.
An existing app that does this is a shopping list app called ShopShop.
The app on my phone and my wife's phone both link to the same DropBox account and the app keeps the shopping list synced up when one of us adds something to the list.

Send data to a SPECIFIC iPhone application through mobile network (No Internet)

I am looking for a way to send data to a SPECIFIC iPhone application without going through Internet... thus using the mobile network.
Thanks.
No chance. There's only two things the phone is actually receiving: calls and text messages. Both cannot be used for what you like to do, since neither can be routed to any app.
You can't even really keep an open socket to allow connections through the internet, since the new multitasking is not really multitasking and allows listening for new data only for a few types of applications, voip clients for example. But you didn't want internet anyway...
Best you can do is text the phone a URL whose schema is registered to your app.

Can two iPhone aplications communicate with each other?

Is it possible for two iPhone apps to communicate with each other by any means like sending messages etc?
EDIT: Also is there any way a system app can communicate with our app?
For example: If I want to play a sound when I receive a phone call, then is it feasible?
Thanx in advance.
Do you mean in realtime? On the same device?
Of course there are uncountable ways to do IPC (pasteboard, -[UIApplication openURL:], via a web-service). The best way to send data depends on the actual use case.
For now two apps cannot run at the same time, so realtime communication would not be possible on one device.
I think that not directly, they're only allowed to access it's own sandbox. You could approach that using Push on both Applications, using an intermediate server to transfer the data between the two apps.
Direcctly it is not possible at all
With intermediate Server they can..
i.e.
One application sends message to server
That server sends same message to Second Application via Push Notification