I'm going to develop few apps for iOS. Can they communicate to each other via sockets? Let's say one app runs as server (even in background mode) and another as client connects to server app and perform some communication. Does it violate any App Store rules? Any available IPC in iOS if my idea is not working for some reason?
2 Answers
As long as your apps are in the same app group, then yes, socket IPC is allowed. If not, then no. Sockets map to file descriptors (Berkeley sockets), and these files are sandboxed to the app or app group. More info: http://ddeville.me/2015/02/interprocess-communication-on-ios-with-berkeley-sockets

- 187
- 10
Of course you can and it doesn't violate any rules.
Just just the CoreFoundation libraries.
There's no point in me describing it to you if it already has been all written in the official Apple documentation:
You can find here examples, all approaches and things you can and cannot do.
EDIT:
You didn't make that clear but it seems like you wanted the apps to run on the same device. You can do that but that would mean that one app has to run in background, and to do that you need some kind of hack (for example: background updating location mode ON) and that won't get past apple store. You need a very good reason to have your app ran in background (music in background, update location in background for fitness apps etc.)
Besides, it's a duplicate question:
iOS - Is it possible to communicate between apps via localhost?

- 1
- 1

- 3,616
- 17
- 32
-
just to be more detailed (though i expect the answer): "iOS app running on the same device?" – 4ntoine Mar 05 '15 at 06:12
-
I dont understand. You want the apps to be on the same device ? – michal.ciurus Mar 05 '15 at 06:56
-
yes at the same device, one as a server and one as a client – 4ntoine Mar 05 '15 at 08:06
-
there are some caveats with listening on sockets in iOS, the trick is to close them just in time, see https://forums.developer.apple.com/thread/85038#253216 – Alex Cohn Dec 31 '17 at 18:41