wo heads are better than one, goes the old saying, and that can be as true for mobile applications as it is the people who write them. Whether you're looking to partition functionality between related applications, or integrate two applications to work together to share data, if you're working in the mobile space, you should understand Brew's interapplication paradigm. This article willshow you how to have applications communicate via launch arguments, events, URLs, and Brew's IFIFO, a kernel-level pipe interface you can establish between applications.
Brew Interprocess Communications Overview
As you already know, Brew provides a single-process execution environment with an application stack. The frontmost applicationthat's the one you're interacting withis at the top of the stack, and other applications that have been previously launched and are suspended are at lower levels of the stack. An application may also run in the background, in which case its context remains loaded and it can receive events from the system or other applications, but shouldn't draw to the screen.
All of these applications can communicate in four different ways:
- Applications may pass events to each other.
- One application may start another and include launch arguments for the started application to process as it begins execution.
- Applications can pass URLs anonymously to other applications (this is a specialized form of launch argument handling).
- An application can establish a fifo to which other applications can write.