0

I have an iPhone application that send datas via wifi on my mac. I would like to send a logout message to my mac when I quit the iPhone app. I tried to send it on the :

-applicationWillTerminate methode

but it seems that the application shut down my service before. How and where can I send my message just before the exit ?

Thanks a lot !

Pierre
  • 10,593
  • 5
  • 50
  • 80

1 Answers1

0

-applicationWillTerminate: is the best possible place that for putting on-exit code for iPhone apps. But your app will be force-killed anyway if the termination takes too long.

Your server could just invalidate the session if there's no response for too long.

kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005
  • Ok so just implement a NSTimer that look if my iPhone send a message (for example 0) every second. If during 5 sec I have not this message I cut off my connexion. But how do you restart properly a server connexion with AsyncSocket ? – Pierre Mar 28 '10 at 14:26
  • @Pierre: I don't know much about AsyncSocket, but you could just reconnect like how the connection was created when the app starts... – kennytm Mar 28 '10 at 14:33