2

We are making an app for the hotel where we have already made an app where orders can be placed through app. All those orders can be seen on web portal by refreshing the page.

Now client requested to create an app where waiter can see the order on his iPad.

For that we will be having the tableview where all list of orders will be shown.

However I am not getting how I will refresh the table/ add the data if new order is made.

In short once order is made, at same instance waiter should get alert and table view should be updated.

Note: iPad/ iPhone get the data through webservice.


This can be achieved by calling webservice every 1 min or 30 seconds.

However I don't want to do this way...

If new stuff is added, webservice will send that data and I will add that data in my tableview. Means webservice will send me listener that new data is added

I need to know how can I listen this listener if webservice send me listener.

Any useful info on this would be appreciated.

Below link helped me for TCP in iOS.

http://www.tekritisoftware.com/sites/default/files/Socket_Programing_for_IOS.pdf

Fahim Parkar
  • 30,974
  • 45
  • 160
  • 276
  • Check new order is placed using background service call to server. If the is placed the reload the tableview data with new new data. – Velmurugan S Feb 09 '14 at 08:42
  • @VelmuruganS : so you are saying alternate 30 seconds I will keep on calling for new order? – Fahim Parkar Feb 09 '14 at 08:42
  • yes, So that only we can check for new orders. – Velmurugan S Feb 09 '14 at 08:45
  • @VelmuruganS : check my updated question... I know we can do this way, however I don't wanna go that way as there is delay of 30 seconds or less ;) – Fahim Parkar Feb 09 '14 at 08:46
  • @ Fahim Parkar : long pooling is in ajax and php to establishing the connection long time, once the server receives the new data, then that will send back to client.Ajax will listen for that response and update in ui. I don't know how to achieve in ios.If you got the solution please update the ans.tk. – Velmurugan S Feb 09 '14 at 08:54
  • @VelmuruganS : for the web based app, ajax is the best solution... I agree... for iOS I am looking something like that funda... – Fahim Parkar Feb 09 '14 at 08:57
  • What about push notifications? Web service notifies about changes via push, and client updates the table (requests new orders) in response to this notification. See docs https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/WhatAreRemoteNotif.html#//apple_ref/doc/uid/TP40008194-CH102-SW7 – vokilam Feb 09 '14 at 11:42
  • @vokilam : I read somewhere **push are not guaranteed**. See [this link by Apple](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html) – Fahim Parkar Feb 09 '14 at 11:50
  • 1
    That's true, but you can combine push notifications with less frequent polling of web service (to be sure). Another way is to keep an open TCP connection (will it work in background?). – vokilam Feb 09 '14 at 11:54
  • @vokilam : I am planning to use TCP, but concern is when Internet connection get broke then what? Trying to search sample tuts for TCP for doing this task... – Fahim Parkar Feb 09 '14 at 11:57
  • @FahimParkar keeping an open socket might drain battery and heat unit (phone). push is unreliable. i strongly recommend that an update be made every time a waiter asks for info on a specific table. instead of working like WhatsApp (pushing), work like email on demand. Using a socket to access a database should not take too long, under normal circumstances and will probably guarantee most up to date data. – tony gil Feb 10 '14 at 13:00

1 Answers1

0

You could implement it using a TCP-based client-server approach, where the iPad is the client.

  1. The iPad client connects to the server using authentication so you know which waiter is using the iPad.
  2. The TCP uses duplex communication over the TCP socket so either side can send a message to the other.
  3. If the server has something to give to the iPad/client/waiter then it simply sends it to them.
  4. If the client wants to send a message to the server, like "I'm taking a break", or whatever, then it simply sends it to the server.
  5. The range of information you can share between the client and server is actually unlimited.
  6. There is no 6.

This requires the server to be written as well, however, so this solution is more than just iOS development. However a webservice would need similar development anyway.

trojanfoe
  • 120,358
  • 21
  • 212
  • 242
  • I am having loggin system to connect to app, so using login id, I know which iPad is which waiter... using webservice I can send data however I want iPad to listen automatically (instead of I write NSURL Connect to read it)... my main concern is listening the data from server by iPad by SOME LISTENER... – Fahim Parkar Feb 09 '14 at 09:13
  • @FahimParkar OK, I've undeleted my answer. I think it's a bit weak anyway. All I am suggesting is using TCP-level comms, not HTTP/JSON/XML/whatever. I would suggest an asynchronous approach as well. As far as examples are concerned is there is wealth of information about how to use TCP sockets in this way on the internet which has been there since the internet started... – trojanfoe Feb 09 '14 at 14:18