How to send images or sounds to another iPhone/Android - iphone

I was wondering how games like Draw Something are sending the images to another iPhone/Android?
I want to be able to send a recorded sound/UIImage to another phone, how are they sent and received?
I'm relatively new to communication using iPhone.
I've googled and searched stackoverflow, but couldn't find anything.. maybe I'm not searching for the right query..
Thanks in advance!

They are sent via TCP/IP to a central server, or more likely, a group of servers. Those servers are responsible for storing the data and generating push notifications so the target device knows that new data is available. The target device downloads it from the central server(s), not directly from the other device.
On iOS, you can use the NSURLConnection class to push data to a server or read it back. The server is something you are also responsible for, although there are some third-party ones that you could use, like Urban Airship, to help with push notifications.

Related

Constantly checking with the server iOS?

I am developing a game for the iOS devices where the application will fetch data from a database (messages). I want the application to update to just to notify the user when there is a new message (and only when the user is in the application or when it is running). What is the best approach to this problem? I was thinking of checking with the server for new messages every 2 minutes, however I don't know how efficient that is. Please let me know if there is a better approach to this or the one I am thinking of is just fine
thanks
Polling the server is a perfectly fine solution. Your email client does it all day long. Push is not a suitable solution (message delivery is not guaranteed and if you only want messages when the app is running that is not the purpose of push notifications). See my answer to this similar question: Web Service sending information to iPhone
You could use push technology from a platform like Urban Airship.

Whats the point in UrbanAirship?

I'm looking into push notifications for an app I'm creating. I've heard lots about UrbanAirship but I can't seem to find a definitive reason why I should use it? As far as I understand it UA is a middle man? This page shows the free version doesn't have a push composer, so a developer will still need a server themselves to create the notification, if their own server is needed then I might as well go directly to APNS?
What is the point and advantage of UA? And if you use it how do you send notifications without your own server?
A working implementation of push notifications involves many things, such as:
Keeping track of Device IDs (web service for the device to contact, database to store the IDs)
Storing metadata associated with each Device ID (ie. so you can refer to a device by a username or a group of devices by a tag)
Keeping track of which devices have been deactivated (which happens if the user turns of notifications)
Clearing out bad Device IDs
Actually forming the raw request to send the message to Apple's servers
Some sort of service/program to know when you need to send the notifications
Urban Airship takes care of 1-5 for you, which greatly simplifies the whole process. Yes, you if were just sending a message to one device, you could probably find a C# or python or Objective-C library to connect to Apple and form the message but as soon as you need to keep track of a large number of devices, Urban Airship provides a service for free (if under 1 million pushes a month) to take a lot of work off your shoulders.
(And this is just for the basic push service for iPhone, as this is the only service I have used)
To answer your other question, you do still need some 'server' or program to know when to push (#6). I, for example, monitor twitter with a python program for keywords and send out notifications when I see those. My program is not concerned with the details of how to send notifications, the Urban Airship library I use takes care of the interaction with Urban Airship and Apple.
If you start your free trial at nextdns, you find urbanairship becomes one of the most common offenders that they block.

Using Remote Notifications In My Application

I am currently starting my way on developing iPhone applications, and I have recently encountered a problem which I could not find a proper answer to.
In my application, I want one iPhone to send a request and another, far iPhone respond to that request using an Alert View, almost like the way Game Center works when you invite someone to play with you.
Do I do that with Push Notifications? Some server? Or what?
Thanks ahead,
A Newbie Developer.
Not the simplest things to try and do when you are new - but have a look at GameKit.
There is a sample application called GKTap which shows how to hook up two iPhones.
Don't be fooled by the word Game. This framework makes it easy to set up communication between phones, even using Bluetooth.
It depends on what you mean by "far". If you mean in another room, but within Bluetooth range or on the same local network, then there is GameKit. If you mean on a different network, or a long distance away, then you are looking at needing to have a server that keeps track of the devices and the connections between the devices so you can use Push Notifications. If you are thinking of something like Words With Friends where it sends a message to another user to tell them it is their go, then you would need the server.

Direct communication between iPhone users

I'm new to iPhone programming. So far I've only written a couple of simple apps just to get the hang of it. In a short time I will have an assignment to write an app that will let iPhone users communicate directly using short messages, and probably they will add a requirement to be able to send files to each other attached to the messages. Of course this sounds a lot like a mail client. For several reasons the client does not want to use mail, if possible, and attaching files would leave SMS messaging out. I've been reading Apple's documentation on local, push and broadcast notifications. Would any of these be the way to go?
Thanks
User bonjour if you are one the same network: http://www.mobileorchard.com/tutorial-networking-and-bonjour-on-iphone/. Otherwise it sounds like you want to use Push. I'd recommend checking out Urban Airship

How to make a chat system on iPhone?

I'm doing research for making a chat based app for the iPhone (it's not really text chat in the regular sense, but the principles are the same).
Maximum 6 people can be logged into the same chat room at any one time, and the most basic question is how to efficiently check for new messages?
Would I need to simply poll the server periodically? Or is there a way I could trigger an event on the phone from the server whenever there is some new content to pay attention to?
If having to poll all the time, I worry about the resulting lag as each participant will have to wait longer for others before they can post their own responses to others. And, potentially it might also be too much to handle for the server to respond to lots of requests all the time. It would also waste bandwidth, which is not free for the user...
Unfortunately I will not be able to set up a socket server for this app, it has to be based around a regular LAMP configuration.
I think you can either go with push notifications, or XMPP (Jabber) server.
XMPP will allow your iphone app to receive data even when in the background using the new multitasking features (listening for a socket), and i'm pretty sure you should find ready to use servers for LAMP (or at least open source implementations).
Note that the iOS4 multitasking API doesn't support polling in the background, so your only other option should be push notifications. If you're new to push notifications, you can maybe use a service like Urban Airship that might make the process easier.
XMPP sounds good for you idea, i think this is the best technology for Chat. It alos works great in iOS apps.
Maybe this code sample will be helpful to start using XMPP in iOS app - look at this QuickBlox Chat code sample. It demonstrates how to integrate 1-1 Chat, Chat in room into your android application. Also there is guide how it works. I think there will be no problem to integrate it into your application. Otherwise - Comments system below allows to ask any question you want and get fast answer.
Also there is Demo video http://www.youtube.com/watch?feature=player_embedded&v=SncQaJBBW_0 how this Chat works.
In my opinion the best solution is socket, but you say that you can't implement the server side for this.
You could also implement it with push notifications. You can receive the push also when your app is running and send all the data you need inside the push. Usually chat messages are short...
If you don't want to mess with push notifications on the server then the only thing left, as long as I know, is the polling.