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

2

5

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.

Dimitri answered 20/8, 2013 at 6:25 Comment(3)
@RamarajuI am facing the same problem, i need to create a chat application using php url, can u pls guide me for this.. thanksOntogeny
@APG We configured our server to support ejabber client. hope that helps :-)Dimitri
using XMPP framework..can you send me some link or sample for more information that will be helpful..xmpp is only the best way for chatter box.thanks for your suggestion@RamarajuOntogeny
G
8

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

Gigolo answered 20/8, 2013 at 8:38 Comment(0)
C
1

As you know that without getapi.php it is not possible to update chat list so you need to make management something like: you need to use NSTimer and with the help of timer you need to call your getapi.php service after certain time interval let say after 2min so that chat can be refresh and user get the reply this is the only possible way at my knowledge.

Cataplasia answered 20/8, 2013 at 7:28 Comment(1)
That's polling and it's bad practice, generally.Ichinomiya

© 2022 - 2024 — McMap. All rights reserved.