Hi!
That being said, I don’t think your problem comes from APE, but from how iOS handle stuff. You can’t keep something running on Safari (either the browser and in app web view) forever. Otherwise, you would consume most of the device ressources (Data & battery life) in background for nothing. There’s a complex way in iOS apps to do that (which I’m not a specialist of). Long story short, that’s why safari close the connexion to APE when in background for too long. From what I experienced, I would say it keeps everything alive for 30-60 secs. After that, background management stuff is needed.
In your example, you probably have an outdated users list when you come back, that’s why you can see the « connected » users (new users probably don’t appear).
The best way to work around this in APE (or other socket type thingy) is to detect when the app closes/go to background (window.onunload in JS or something like applicationDidEnterBackground & applicationWillEnterForeground in your AppDelegate on iOS native), tell the server to hold on to the message it need to send to you and close the connexion. When you come back, you get from the server what happened while you where away and restore the connexion. While in background, Apple Push Notification (APN) should be used from the [APE] server to notify the user (way more simple and efficient).
Again, depending of what exactly you want to do with APE on iOS, APN would probably be way some simple to use than an APE solution. The only advantage I see to using APE (or other socket type connection) in an iOS app is if the volume of notification/data being sent (request per second) is really high. For low volume, it’s much easier to stick to APN / NSMutableURLRequest.
It’s very experimental and has never been tested on a real life App Store available app (My App got rejected for unrelated reasons before I could implement APE in it), but you will get a global ideas on how it works.
- Louis