Automation of everyday tasks with scripts and interapp communications has been a tool for power users on computers for years. However, iOS has always been sorely lacking in the area. Apps on iOS are sandboxed, meaning they are only allowed to interact with the operating system in certain ways specified by Apple. It also means that they are severely limited in their ability to intereact with each other. This means that all apps are trapped in their own little boxes, unable to access anything except the basics, like pictures, contacts, and calendars. However, clever developers have managed to find a way around a great deal of these limitations: URL schemes.
Much like how website URLs lead to specific pages within a website, app URLs can lead to specific places within an app. For instance, the basic "apple.com" URL will lead you to the home page of Apple's website, but if you type in "apple.com/iphone", you will bypass the home page and go directly to the page for the iPhone instead. App URLs work in the same manner. Using my favorite app, Drafts, as an example, if you type drafts:// into Safari on iPhone or iPad it will take you to the "home page" of Drafts. In other words, it will open Drafts as if you had just tapped on the app on your home screen. However, the power of URL schemes lies in the deeper integration. Just like adding "/iphone" in our example takes you deeper into Apple's website, adding terms to the end of "drafts://" will take you deeper into the Drafts app, and can even perform actions that would normally take multiple taps and swipes without you having to do anything except open a URL.
App developers have discovered that URLs are one of the only things that apps are allowed to pass back and forth to each other while still staying in the confines of Apple's sandbox. They have exploited this trick as a sort of back alley root to allow interapp communication on iOS. Here's how it works:
If you're in Safari, Chrome, or any other web browser, and you type "drafts://" into the address bar and follow the URL, then instead of going to a web page iOS will leave the browser app and open Drafts app (assuming you have Drafts installed, otherwise it will do nothing). If you go deeper, you can type in something like "drafts://create?text=Hello World!". Then you will leave the browser and enter Drafts where a new Draft will automatically be created and populated with the text "Hello World!" Sounds cool, but kind of useless, right? That's where apps like Drafts and Launch Center Pro come in.
Just like how iTunes used to be your "digital hub," where you would connect all your devices and sync all your apps and music, apps like Drafts and Launch Center Pro seek to become something like your "Communication Hub." These apps work by leveraging URL schemes to allow you to send text and actions out to other apps on your device. You type text into your "hub," and it distributes the text to anywhere you want, as long as the app it is sending to has implemented a URL scheme. For example, I can create an action in Launch Center Pro that will prompt me for text and then send that text to Safari which will perform a Google search of it. I can use this method to search in other places too: App Store searches, iTunes searches, Wikipedia, Terminology, Wolfram Alpha, Yelp, and many more, all from my central hub of Launch Center Pro. This means I can focus immediately on what I am searching for instead of wasting time finding the app to search from, finding the search box in the app, and then recalling what it was I was looking for. This same approach can be taken for many other actions besides just searching (i.e., texting, tweeting, posting to App.net or Facebook, calling a contact, etc.), and all of them can be performed from the exact same place. An avid user of Launch Center Pro myself, I can personally attest to the huge increase in speed and productivity that these methods can create. Still, while rapidly performing single actions from one spot is cool, it's not very complicated automation. That's where Drafts comes in. Drafts has taken Launch Center Pro's efforts even further, leveraging the power of the x-callback-url alongside a complex and robust built in URL scheme to allow users to chain multiple actions through multiple apps with a single tap.
The x-callback-url is a specification created by Greg Pierce. Pierce, not by conincidence, is also the developer of Drafts. X-callback-url is something that developers can freely implement into the built in URL schemes of their apps to allow them to send a "success" parameter after completing a certain action. It is very similar to an "if, then" statement in programming. If the app successfully performs a specified action, then do something else afterwords. This specification is what allows apps to chain back to one another. For instance, I can use Drafts to send text to Due, a reminder app. Due will prompt me to create a reminder with the text I wrote in Drafts, and when I successfully create the reminder, Due can then automatically send me back to Drafts. This would not be possible if Due's URL scheme did not include the x-callback-url: Due would then be unable to see when I successfully created the reminder, and thus would not know when to run the scond part of the action and send me back to Drafts.
So with the combined powers of the Drafts URL scheme, the ability of apps like Drafts and Launch Center Pro to create and run custom URL actions created by the user, and the x-callback-url, automation is finally possible on iOS. Here's an example: one way for me to post to my website is by emailing an HTML document to a specific email address. When the message is recieved, it is posted to the site. I can do this on my iPad, but it takes an inordinate amount of time and many steps. I write the post as a draft in Markdown format, but then what? First, I copy the text, then I exit Drafts and open Notesy (A dropbox enabled note taking app that supports converting Markdown to HTML), then I paste the text into a new note in Notesy and convert it to HTML (which automattically copies it to the clipboard), then I close Notesy, find and open Mail, tap the compose button, paste the HTML into the body, type in a subject (used as the title of the post), and type in the recipient email address that will post the text to my site. All of this can take almost a minute, and it is an extremely clunky and annoying process. However, with the techniques for iOS automation that I mentioned above, I have managed to condense the entire workflow into a series of actions that can be triggered by one single action in Drafts, like a Domino effect. The action, renderMarkdown, first takes the text I have written in a draft in Markdown format and sends it to Notesy using the Notesy URL scheme. Notesy receives the Markdown and automatically converts it to HTML, then copies it to the clipboard. Drafts cannot (yet) create a new draft with text from the clipboard, but another great app for aiding in iOS automation, Pythonista, does have access to the clipboard. So the text is sent from Notesy to Pythonista, where a super simple Python script I wrote creates a Drafts URL action with the HTML from the clipboard as the text, and follows the URL. Drafts is reopened and creates a new draft prepopulated with my HTML, then calls an email action I made to create a new email message with the recipient address filled in with the necessary email address to post my HTML, and fills in the body of the message with the HTML itself. The only thing I do is type in the subject of the message and hit send.
All of that may sound extremely complicated, but in action the entire process takes less than five seconds between me running the renderMarkdown action and typing in the subject of the email. Everything else is done automatically, saving me quite a bit of precious time and preventing me from having to deal with the annoyance of copying and pasting and moving between apps and remembering the email address to send to, etc. This is the power granted to us by URL schemes, Drafts, and x-callback-url. This is the power that power users have been waiting for.
If you're interested in getting your hands on any of the actions I've made, or have some of your own you'd like to share with everyone, I encourage you to visit The Action Page, a page I've started right here on The Axx as a source for all advanced iOS automation actions and scripts, and to collect the latest news in this rapidly advancing new field for iOS.
Thanks for reading!