tags:

views:

58

answers:

1

Hi,

Can anyone give me a guidance for implementing a chat appln in iPhone.

Regards, Sreelash

A: 

sure its good idea. you need to study how socket works in iphone. Also such application need to have an intermediate server that will monitor all activities i.e. who is online, who is chatting, what was the last message sent and store it in chat history etc.

So what this app needs to do is provide user with registration and login screens that will occur with the remote server and its implementation is pretty obvious.

So when user signs in you need to record that information that he is available in the server using NSURLConnection class and same for the sign out.

When user signs in you need fetch list of his friends from server and populate UITableView or any other view you are using. That list must be in JSON format that should tell him which is friend is online since we are recording that information whenever any user signs in.

Now whenever user touches on any of his contacts then get there ipaddresses(record that information too when user signs is) and create socket between them. In the mean time when they are communicating then you need to send each information to the server say when they click send message button using NSURLConnection, that will usefull if they want to have chat history.

Thats it you, follow these steps and you can have nice chat application ready within few days. Also for JSON and sockets use libraries that are available for example touchjJSON etc.

Ayaz Alavi
thanks Ayaz, you said what all i actually needed. But i need some good tutorials for socket programming in iPhone using Objective C. I am a newbie in iPhone applns. Just started 3 weeks before only. Now i had just familiarize with cocoa frame work and basics of objective C. Then i have created the user interface for this chat application.i have the programming knowledge in flash-AS3 and Silverlight C#. Is there any need to use Wi-Fi or GPS for identifying the persons who came online? Have u ever did this sort of application? Thanks and regards,Sreelash
Sreelash
you need to make sure that Wifi is enabled because this application is totally depending upon internet. If wifi is not enabled on users iphone and your app failed to detect it then apple reject this app because applications that involve internet usage needs to handle it properly.
Ayaz Alavi
see links http://discussions.apple.com/message.jspa?messageID=7774528#7774528 , http://beej.us/guide/bgnet/output/html/multipage/index.html , http://oreilly.com/iphone/excerpts/iphone-sdk/network-programming.html
Ayaz Alavi
Hi AyazIn our application, we need to identify the users who are online within certain distances. Isn't this possible? For example, if i have searched for users within 1 km or any distances that are online. Can we identify them with this critereia? Isn't this possible?Thanks and regards,Sreelash
Sreelash
it is possible. see iphone sdk mapkit. you need to store user's location in database the time of sign in. map kit can provide you with lat/long pair of user's current location which can be stored in database. Then with custom sql function you need to make sure that returning data set with list of friends has lat-long pair that is 1km away. See this http://www.movable-type.co.uk/scripts/latlong.html and http://blog.objectgraph.com/index.php/2009/04/08/iphone-sdk-30-playing-with-map-kit-part-3/
Ayaz Alavi
Hi Ayaz, I have started research on socket programming. I have a doubt regarding the connection between two iphones for chatting. When two persons are chatting from different iPhones, we need to establish connection directly between those iPhones or connecting both through a webserver. Which one is relevant for a chat application?Regards,Sreelash
Sreelash