4ntoine
4ntoine

Reputation: 20422

Can iOS apps communicate via sockets?

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?

Upvotes: 3

Views: 2973

Answers (2)

Garvan Keeley
Garvan Keeley

Reputation: 187

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

Upvotes: 2

michal.ciurus
michal.ciurus

Reputation: 3664

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:

https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/UsingSocketsandSocketStreams.html

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?

Upvotes: 1

Related Questions