0
votes

I'm making simple iOS messenger with XMPPFramework. So the problem is, that if i app goes into background it's disconnects from XMPP server, so the only way to store incoming messages without opening app is Push-notification (add message var into push), which is not so good way. Also, ma app make phone acting as iBeacon to track locations of other near phones. As i know, with such capability app can stay active even in background, but can i also hold's XMPP connection while i'm in background, tracking iBeacons? Or Apple finds out and reject such app?

Thanks for help?

1

1 Answers

1
votes

It is important to distinguish between an iOS app running in the background and one that has been suspended.

Yes, you can use beacon trasmissions to keep your app alive in the background. When it is alive, you can do networking events in the background including XMPP calls.

There are limits to how long a beacon detection can keep an app alive in the background.

On the receiving side, by ranging and monitoring for beacons at the same time, you can keep it alive for 10 seconds for each new beacon region that appears/disappears, and you can extend this to 180 seconds on request. It is possible to game this system by rotating the beacon transmitted every 2 minutes to ensure there is always a new entry/exit event.

On the transmitting side, iOS devices can only transmit iBeacon packets when they are in the foreground. So the best you could do is keep the receiving app alive in the background and communicating with XMPP whenever there has been another app in the foreground within beacon range (~50 meters) within the last 3 minutes.