Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Communicate transparently between apps running on the same iPhone

There are a number of similar questions so this one is carefully scoped not to be a duplicate.

Preconditions

  • There are two iPhone apps (separate bundle IDs), and you have full control over the source code of each one
  • The user has both apps installed on the same phone
  • No network connectivity to other hosts
  • No jailbreaking
  • Assume the apps have proper capabilities to run in the background indefinitely

Goals

  • Communicate bidirectionally between the apps
  • Minimize or eliminate user-observed evidence that such communication is taking place
  • Background app will have new information that needs to go to the foreground app, so need push or polling mechanism
  • Ideally could be used in production and so doesn't use private APIs

So the question is "Can it be done?"

What follows are some notes on "Already tried" - different approaches that have been considered.

Well understood attack vectors

  • Use another host - reasonable, but excluded in the problem definition because of latency
  • Custom URL schemes - a pretty good approach, but not ideal because of animations and context switches, especially if polling
  • Stuff under Settings.app -> Privacy (e.g. Contacts) - would work, but would rather not ask for permissions

Things that probably won't work

  • "Open in..." api
  • Shared filesystem in some way
  • Bluetooth

Possible ideas

  • Inter-app audio
  • Localhost socket - Is this the best approach?: iOS - Is it possible to communicate between apps via localhost?

Apple has carefully avoided exposing this functionality. Has anyone figured out a way to do it anyway?

like image 448
funroll Avatar asked Mar 04 '14 19:03

funroll


People also ask

Can iOS apps communicate with each other?

Beyond the sandbox: using app groups to communicate between iOS or macOS apps. Apple's “app group” technology allows a collection of sandboxed macOS or iOS apps from the same development team to all communicate with each other, coordinate functionality, share resources, and/or minimize redundancies.

How do you use two of the same apps on iPhone?

With an app already placed on your home screens, go to the App Library, locate the same application and long-press to drag it. You can then place it onto a home screen and your existing icon will not be removed. iOS 15 also enables drag-and-drop for apps in Spotlight search.

What is inter app communication?

It is based on the share_target definition in the app's Manifest file. This way the user is able to send data to the specified endpoint in the application from any other application (Web or native) installed in the system.


1 Answers

One more idea: start local web server in one apps on iPhone and use it for communications between apps.

Here is implementation of such server

And here is usage example

I haven't tried this solution by myself but saw apps that use this idea for communications.

Also, I believe that Apple intentionally not implement any easy way to communicate between apps. Now you can make you app like it is the only one application on the whole device with little exceptions like memory usage and etc. As soon as here will be some easy way to communicate between apps we will found ourself in much more complicated environment. We will need to consider much more limitations, rules and possibilities as programmers.

But I also would like to have some way to communicate between apps, many great ideas can be implemented with this tool.

like image 96
Vanger Avatar answered Sep 19 '22 00:09

Vanger