Does Apple permit the usage of socket for communication between two iOS apps? - ios

So basically I have two iOS apps installed on the same device, and they need to communicate by sending data to each other. I don't want to use URL scheme or Universal links as these two would open the other app in UI instead of sending message to each other in the background. Currently I have a solution of using a unix socket connection by binding one app to a specific port and have another app connect to it. This works fine but I am just wondering if Apple would allow the usage of this.
Note that these two iOS apps do not come from the same developer so anything else that relies on App Group would not work in this case..
Would Apple allow using a socket in this case?
Edit: One of the app is valid to run in background, so background execution is not a problem

No, this is not possible simply because the application will lose network connectivity when it goes into background mode. I invite you to check the following Apple Developer Documentation page related to iOS app background modes:
Background Execution
As you can find on the page, the operating system suspend the app when it moves to background and will then cut several resources including network access.
There are however some exceptions to the rule, which are voice ip apps. These must declare the voip background mode in the plist file to be allowed to keep network streams open in the background.
This question comes a lot on iOS or Android and unfortunately the answer so far is no, we can do tcp client / server communication between apps.

It is totally doable as long as one of your apps has permissions to run on the background. Such example is music apps. Spotify does the same thing with their “app-remote” SDK.

Related

Is it possible to stop traffic from specific ios ports using MDM

Is there anyway to block the use of certain ports from the use of an ios MDM like jamf? Say that you wanted to stop VPN's from being allowed? Short of blocking every downloadable VPN from the app store, is there a way to prevent users from using these specific ports on their ios devices without closing off ports via a firewall?
Originally I was thinking about an apple app store keyword based block, but the Jamf MDM doesn't allow this.

Publish IOS App to Appstore with SSID ( wifi) discovery/connect through app

I was trying to get a specific info before a IOS App development task which I searched but couldn't find anything relevant.
Wanted to know whether this requirement restricts (non compliance issue as per publish guidelines) the app to be published in App Store with features as below
User scans and lists all available wifi connections in a tableview
Selects one of the Wifi connection and connects on button click
Stores the password and SSID for future connections.
Would there be any compliance issue related to the same functionalities when submitting to IOS app store. One of my colleague have advised me about the same but not able to explain why? Which I tried to find out searching the internet, but too specific to find anything relevant. Deeply appreciate an Expert advise on this.
Thanks in advance.
I can't find anything in the Review Guidelines that would object your app idea: https://developer.apple.com/app-store/review/guidelines
A couple of areas where you should have a more detailed look:
2.5.1 Apps may only use public APIs.
2.5.9 Apps that alter the functions of standard switches, such as the Volume Up/Down and Ring/Silent switches, or other native user
interface elements or behaviors will be rejected.
5.1 Privacy
Technically, I'm not sure if it's even possible to change the WIFI not via the settings app, so I'd have a look their first. (https://apple.stackexchange.com/questions/1592/is-there-an-ipod-app-to-easily-switch-wifi-on-and-off)
I don't believe I've ever seen an app or a way to change SSID outside the Settings app. I explored a way to detect network changes, connects, disconnects, which work fine while the app is running. I was never able to influence how the user connected, just that a change happened. It also falls apart pretty quickly when the user backgrounds the app. Trying to keep a background task open long enough to poll the current connection fails pretty fast.
I wish Apple would provide some system level notification of Wifi connect events. This could be very useful to developers that want a little more control than Background App Refresh events.

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.

iOS using sockets to talk to other apps

Is it possible to have 2 apps on 1 iPhone/iPad talk to another via sockets? For example The main app is phonegap app that just displays data and when the user clicks the print button, the 1st app sends data to the 2nd (2nd app stays in the background, I guess it is a service), it (the 2nd app) then sends that data to a printer that it knows how to talk to whether that is via a webservice call or something else.
From my scan of the docs and other questions it seems the custom URL is one way to make the apps talk, but I want the receiver app to stay in the background. So do I have to use a server/client approach to this? Is that possible.
Sure you can. Just make sure your 2nd app - the background app is conformed to Apple's requirement to run in background modes. You can also use Bonjour to aid in discovery or just pre-selected a port and make other apps aware of it value.
No, there is no socket-based interprocess communication between apps on an iPhone, nor is there any concept of apps as background services. Using custom URLs to launch another app is the only direct method of communication between apps.
On the other hand, if the 2nd app is talking to a printer (or anything else) via a web service, I'm not sure why you wouldn't just have the 1st app use that web service to print directly. Is there a particular reason you need a background app to perform this function?

Can an iPhone application running in the background transfer data via USB interface?

There are 2 iPhone applications. One application running in the foreground and the other running in the background. Is there any way to get the background application to send data over USB without coming into foreground? Ideally we want to keep the foreground app in the foreground, while the background app process some data. Once the data is processed it will inform the foreground app that the data has been processed.
No it cannot. It cannot even do this without the use of private frameworks, unless you're in the Made for iPhone program. If you are, then your organization will know, based on the documentation made available to you, what you can and cannot access, when and how.
Should you be in the Made for iPhone program, and are unclear as to what you have access to and when, contact the person in your organization who is the technical contact with Apple for this program, they will be able to give you the details.
If the task is started while the app is in the foreground and you call the appropriate beginBackgroundTask/endBackgroundTask methods, you should be able to have it continue running after the app is backgrounded.
Note that access to USB is restricted (see jer's answer) and that there's no officially sanctioned way to communicate between different apps on the same device. Also, you can only buy/download one app at a time in the App Store and I can't see Apple approving an app that required you to download a second app for it to work. So you may have bigger problems to solve first.
It would help significantly if you told us what you actually wanted to achieve. For example, "I want MyApp on the user's phone to communicate with MyApp on the user's computer".
The absolute easiest way is to send data between the phone and a computer is to require that they're both on the same Wi-Fi network. Several iPhone apps incorporate a web server (this was the easiest way of "file sharing" before OS 3.2), and many more iPhone apps connect to a computer running server software.
Your other options, more or less:
Reverse-engineer the Bluetooth side of GameKit and reimplement it on the computer-side. I'm not aware of anyone who's done this. Loosely, I think it's IP over Bluetooth PAN plus some sort of Bluetooth service discovery.
Audio input/output, e.g. the headphone jack or certain pins on the dock connector. I'm not entirely sure how the mic side works (the resistance was a bit high for a carbon mic when I checked), but you might get lucky and find a way to turn it into "line in" or find "line in" pins on the dock connector.
A webcam pointing at the iDevice screen (and the iDevice camera pointing at the computer screen). Ewwwww.
Join the MFi program.

Resources