Safari-x-success

A hack to get Mobile Safari to mimic Chrome on iOS's back button behavior.

View the Project on GitHub josephschmitt/safari-x-success

What?

On iOS, the x-callback-url protocol is a system a clever developer came up with to give applications a way to communicate with each other. One of the things applications that conforms to this protocol can do is communicate with another app after a primary action has been performed. For example, if you launch Tweetbot from the Drafts app, you can tell Tweetbot to return to Drafts once a tweet has been posted.

However, since x-callback-url isn't built-in to iOS natively, Apple's apps — such as Safari — don't support it. xsuc.es attempts to bring this functionality to iOS's default browser, Safari, through the use of a blank webpage and some JavaScript.

Why?

Well, Chrome for iOS uses this x-success stuff to great effect: it gives the browser a back button to return to the app it was launched from. So, if you open a link in Chrome from Tweetbot — or a mail client like Gmail — you'll get a back button in the browser to return to Gmail once you're done with the webpage you're on.

This is a much nicer and quicker flow than tapping on the tabs manager, closing the tab, double-tapping the home button, switching apps, etc. Trust me on this.

Sooo... how does this all work?

It's simple, really. Instead of opening up a URL directly, you open the URL to xsuc.es and pass in some extra options:

So what does this look like when you put it all together? For the example in the above section, something like this:

http://xsuc.es/#url=http://macstories.net&x-success=tweetbot://&x-source=Tweetbot

This will load up the MacStories home page, and when you tap the browser back button, it'll bounce you back to Tweetbot. And that's it! If you want to find out more, check out the project on GitHub, or read all about it on my blog.