简体   繁体   中英

Is Inter Process Communication possible between iOS applications using Sockets?

I have gone through a lot of articles on internet and most say that IOS applications allow IPC using protocol handlers (URL Schemes). But, Can't we achieve IPC using sockets, if one application opens a port and the other tries to connect to it ?

iOS8 introduced IPC support by exposing mach ports for so called "application groups". Check out this great tutorial:

http://ddeville.me/2015/02/interprocess-communication-on-ios-with-mach-messages/

It requires a bit of setup (to define application groups in dev portal, generate proper entitlements, etc..) but is not really so difficult and Xcode 6 does most of the job automatically (just enable "App groups" in general capacities section).

I can confirm, it works (I was able to create 2 apps sending messages to each other).

On iO7 there is no official support for IPS, but If you do not plan to upload your app to AppStore, you could try to exploit inter-app audio communication to achieve this. Check out Apple's code sample, which demonstrated inter-app sound data stream between 3 apps:

https://developer.apple.com/library/ios/samplecode/InterAppAudioSuite/Introduction/Intro.html

Associated WWDS video:

https://developer.apple.com/wwdc/videos/#602

I haven't try to exploit it for non-audio usage but can't see the reason why shouldn't it work. Data rate is great, and sound data are just bytes and do not have to be redirected to the speaker, but interpreted however you like.

Of course, it will be rejected in AppStore review, but it is still fine for enterprise or own usage.

No, it is not for several reasons. 1) Apple does not allow this internally and has security layers to prevent this. 2) Applications fire applicationDiD/WillEnterBackground after a short delay, at which point the way you can interact with it plummets.

If you really want to send data between applications, set up a server with certs to match your app so you can use APN (apple push notifications) to send data in silent pushes to applications. Then, set up endpoints on the server that trigger those sends, and have apps consume the API that the server exposes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM