x-callback-url for iOS Interapp Communication

x-callback-url is an unofficial spec for iOS interapp communication.

The goal of the x-callback-url specification is to provide a standardized means for iOS developers to expose and document the methods they make available to other apps.

If you want that your iOS app can be invoked from other apps or websites you can register URL types in your Info.plist like this:

http://soenkerohde.com/img/xcallbackurl.png

The example above can be invoked with: test://x-callback-url/action?foo=bar Additionally to parameters you are also encouraged to specify x-success, x-error, e-cancel and x-source. These are urls (except x-source which should be the name of invoking app) which will be invoked when the action is completed, was canceled or failed. If your app (which in this example registered myapp as an x-callback-url scheme) wants to use the test app to do a task the call could look like this (Specs):

test://x-callback-url/post?text=Foo
&x-source=My%20App
&x-success=myapp://x-callback-url/post-success
&x-cancel=myapp://x-callback-url/post-cancel
&x-error=myapp://x-callback-url/post-error

However, please consider the implications. When implementing to call the x-error url after completion the user is also leaving your app again.

“Bad app” could look like this:

function spam(){window.location =
  "test://x-callback-url/post&text=spam&x-success=badapp://x-callback-url/bam";}

document.addEventListener("invoke", spam, false);
document.addEventListener("resume", spam, false);

You should consider x-callback-url as an API to your app which is better bullet proof. Also be aware that the URL scheme should be unique. If two apps have the same URL scheme registered only one gets actually invoked. Not sure how this is determinated.

Comments are closed.