0

I am building a very simple messenger app just to get my feet wet with this type of app. The general idea that I came up with is: Client 1 types a message, sends to client 2. Message goes to my tcp/http server, then the message is sent to Client 2. I am not sure however how this last step happens.

How can the server locate the phone and push the message to it? Should the app check every few seconds to see if they have a message waiting? How would you do this if the app is suspended (background)?

Would this qualify under background fetch under UIBackgroundModes?

The app regularly downloads and processes small
amounts of content from the network.
William Falcon
  • 9,813
  • 14
  • 67
  • 110

1 Answers1

1

You can do it remote push notifications using apple's APN (apple push notification). Essentially, once the server receives the http/tcp message, it has to do a push notification to the device 2 thru apple's apn server. More information here

Pradeep Mahdevu
  • 7,613
  • 2
  • 31
  • 29
  • but this doesn't guarantee that a message will get there... Also I'm not sure you can use this volume of APN. How does whatsapp do it? – William Falcon Oct 08 '13 at 21:28
  • Yes, there is no guarantee. But that is the only way you can push the message to the client. There is one more newer alternative from ios 7 onwards. The app can regularly download and processes small amounts of content from the network. Enabling the Background Modes option adds the UIBackgroundModes key to your app’s Info.plist file. More [here](https://developer.apple.com/library/ios/documentation/iphone/conceptual/iphoneosprogrammingguide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html#//apple_ref/doc/uid/TP40007072-CH4-SW20) – Pradeep Mahdevu Oct 08 '13 at 21:47
  • Just reread your edited question. You can do that, or you can wake your app with remote notification. I know it is not guaranteed but here is a great thread about [apn reliability](http://stackoverflow.com/questions/13897575/apns-apple-push-notification-service-reliability) – Pradeep Mahdevu Oct 08 '13 at 21:50