简体   繁体   English

在同一iPhone上运行的应用程序之间透明地进行通信

[英]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 两个iPhone应用程序 (单独的软件包ID),您可以完全控制每个应用程序的源代码
  • 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 理想情况下可以在生产中使用,因此不使用私有API

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 自定义URL方案 - 一种非常好的方法,但由于动画和上下文切换而不理想,尤其是在轮询时
  • Stuff under Settings.app -> Privacy (eg Contacts) - would work, but would rather not ask for permissions 在Settings.app - > Privacy(例如Contacts)下的东西 - 会起作用,但宁可不要求权限

Things that probably won't work 可能不起作用的事情

  • "Open in..." api “打开......”api
  • Shared filesystem in some way 以某种方式共享文件系统
  • Bluetooth 蓝牙

Possible ideas 可能的想法

Apple has carefully avoided exposing this functionality. Apple小心翼翼地避免暴露此功能。 Has anyone figured out a way to do it anyway? 有没有人想出办法呢?

One more idea: start local web server in one apps on iPhone and use it for communications between apps. 还有一个想法:在iPhone上的一个应用程序中启动本地Web服务器,并将其用于应用程序之间的通信。

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. 此外,我认为Apple故意不实施任何简单的应用程序之间的通信方式。 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. 但是我也想在应用程序之间进行一些沟通,可以使用这个工具实现许多好点子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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