0

I am new to IOS, and I am wondering how to run a cron job on the app.

So for example, a way to track:

  • when someone has gone offline/online in a chat, and display this in real time to the opposite user.
  • a way to constantly track the location of the user whilst they are using the app.

and so on.

I am aware that one can use "background services", but this only seems to work if they are outside of the app, what if I want to track the persons current location whilst they are using the app and update my model accordingly.

How can this be accomplished, cheers.

bobo2000
  • 1,779
  • 7
  • 31
  • 54

2 Answers2

0

You should use websockets or polling, but don't know how to implement this in this case because I don't know about titanium mobile.

Maybe this presentation can help you out: http://www.slideshare.net/etnatraining/ticonf-realitimeappscalanducci

Koen.
  • 25,449
  • 7
  • 83
  • 78
  • Is creating a JavaScript script and running the code that calls the data on a timer a good way to do it? (titanium uses javascript) – bobo2000 Jun 07 '14 at 11:32
  • That would be polling, so thats ok. But websockets are realtime and are probably more performant – Koen. Jun 07 '14 at 15:22
0

Very simple.

Offline/Online status in a chat

Use Sockets or WebSockets for the most accurate informations.

Tracking a location

This depend on how often do you want to do it. If (For instance every second) then do it using Sockets/WebSockets if you want to track a client every five minutes I would choose just basic POST request using XHR.

0101
  • 2,697
  • 4
  • 26
  • 34
  • Thanks, a quick question, why use sockets and not a http request object, are they not the same thing? – bobo2000 Jun 09 '14 at 11:54
  • also once i get the updated data from the socket, how do i update the view, given its already been set – bobo2000 Jun 09 '14 at 12:12
  • Why Sockets/WebSockets: http://stackoverflow.com/questions/14703627/websockets-protocol-vs-http. Do you mean just View or TableView? Anyway I think that you should create another question for this... – 0101 Jun 09 '14 at 14:38
  • View, i.e. where you load up your controller and place elements on the screen. – bobo2000 Jun 09 '14 at 17:45