Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement dynamic chat application in Ios using php, Something related to Skype like application

I am trying to implement a chat application in IOS. In general We use two php files one for posting a message(sender) another for retrieving the message(receiver).

I want to accomplish the following: Consider A(sender) and B (Receiver).

A sent message to B. And A is waiting for B's reply. So i need to call post-api.php for sending a message and at the receivers side(B) i need to retrieve using getapi.php when B reply to A it must automatically appear in my inbox(live chatbox) of A, without calling getapi.php. I know this scenario is not possible. But is there any solution or method so that my chat application works like skype or facebookchat.

like image 367
Ramaraju.d Avatar asked Aug 20 '13 06:08

Ramaraju.d


1 Answers

There is multiple way to implement the chat functionality.

  1. Polling: Send request to server and process the response from the server in timely fashion after a particular time interval using NSTimer(But remember is will cause the battery drain).

  2. Using APNS: Using the official Apple push notification implementation, whenever there is new entry in chat table on server side send the notification to particular device using push notification and handle the notification using the delegate methods (Although not 100% reliable).Using Push Notification

  3. Using Socket Programming: Using the socket programming you can have dedicated connection between client(device) and server. I have provided the link having the source at the end of the tutorial.Using Socket Programming

like image 164
Gyanendra Singh Avatar answered Sep 19 '22 07:09

Gyanendra Singh