And now that the Felicitous NDA has been put on death watch, people aren’t wasting any time at all starting to share tips! Whilst we personally wait for an actual revocation of it, we’ll share public posts by those of a more cavalier bent. First out of the gate, we recommend this fine post by Craig Hockenberry of IconFactory talking about a rather clever solution — and we’re all about the clever — to the job of integrating tasks:
Since your application’s scope is limited to one task, users will depend on it when they want to perform that task. Even if that task is in the context of another application.
An example of this is sharing photos. Users know that the Camera application takes pictures and that the Mail application sends messages. You don’t see a camera button in Mail; you see an “Email Photo” button in your Camera Roll. The user’s first task it to take a picture and the next task is to mail it.
Since we’re not Apple, we can’t achieve the high level of integration between the Camera Roll and the Mail application. But we can use URL schemes to accomplish much the same thing…
That’s an interesting approach. Generally we think of URLs solely in terms of delegating content handling from a webpage link, but certainly applications could use it to integrate directly. The example project they posted, “Redacted”, demonstrates the use of this by defining the “twitterrific” URL scheme for posting to this Twitter thing which those crazy kids are so excited about:
You could write your own Twitter update code using a NSURLConnection, or you could use one line of code like this:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"twitterrific:///post?message=EASY"]];
That’s pretty simple, all right. However, there are some caveats to be aware of:
Not to dampen your enthusiasm, but please be aware of a couple of limitations with URL schemes. First, there is no way to know if a URL scheme is supported or not (rdar://problem/5726829). Currently, the best you can do is to performSelector:withObject:afterDelay: then openURL:. If the selector gets called you know that the URL failed to open. Also, be aware that deleting an application can sometimes leave the URL registration database in a state where it no longer recognizes a scheme (rdar://problem/6045562). This only happens when two applications support the same URL scheme, so you can avoid the problem by using a unique scheme name. Please use the Radar bug ID# for a “me too” bug report if this becomes a problem in your own application.
Despite those caveats, an interesting technique indeed that all of us should look for ways to support in our application:handleOpenURL: methods, indeed!
h/t: Daring Fireball!
