URL Scheme Intro for App Developers

Creating URL Schemes:

At the simplest level, a custom URL scheme allows users to open your app from other apps. But the true power of URL schemes is in the ability to perform specific actions as your app opens.

Here are some examples, progressing from simple to complex:

Open Flixster:

flixster://

Open Simplenote and start a new note:

simplenote://new

Open Yelp and search for “Coffee” nearby:

yelp4:///search?terms=Coffee

Open RadarScope to a specific coordinate:

radarscope://viewInMap?lat=0&long=0

Possibilities are endless! Some app developers provide a couple common links, while others provide deep links to just about everything.

The Basics

No Code Required. In the Info tab of your target:

  1. Click “Add” and select “Add URL Type” to create a new item.
  2. Enter one or more URL schemes in the field, separated by commas.
  3. There is no step 3!

So with that, a user can now open this app with either of these URLs:

snowcrash://
crashmetaverse://

URL Naming Tips…

Apple does not enforce unique naming for app schemes. If you use the same scheme as another app, iOS has no way of knowing which App to launch. In practice, this is a major source of confusion and bug reports. You’re much better off picking a unique URL scheme.

movies:// == bad
myawesomemovieapp:// == good

Taking it Further

The true power of URL schemes is in the ability to perform specific actions as your app opens.

Handling URLs

In your Application Delegate, add this method:

1 2 3 4 5 6 7 8 9 10 11 12 13 14
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
 
NSLog(@"url recieved: %@", url);
NSLog(@"scheme: %@", [url scheme]);
NSLog(@"query string: %@", [url query]);
NSLog(@"host: %@", [url host]);
 
// handle these things in your app here
 
return YES;
}
view raw gistfile1.m hosted with ❤ by GitHub

Anytime your app is launched (or resumed) from a URL, this method will be called. You then may respond accordingly within your app. How you structure your URLs is completely up to you.

Advanced

If you’re looking for even more URL scheme fun, you may want to check out http://x-callback-url.com/. It’s a great way to facilitate collaboration with other apps in the App Store.

Once you’ve added updated your URL schemes, be sure to let us know!

Powered by Zendesk