Reputation: 341
On my iPhone, I'm running an app called Caissa Chess. After registering the app with the manufacturer (this is optional) I received an email, containing a chess puzzle. The crucial part of the mail message, showing a chess diagram looks like this:
<a href="chess://puzzle/8/p1R3p1/4p1kn/3p3N/3Pr2P/6P1/PP3K2/8 w ?term=w2&solution=c7xg7&description=Amura%20vs%20Carlos%20Bulcourf%2C%20Villa%20Ballester%2C%201996"><img src="cid:image1"></a>
Tapping the diagram displayed by this URL quits Mail.app and opens Caissa Chess, that then displays the diagram, and allows you to solve the puzzle.
How does this work?I want to make a little app for the iPhone, that will need an external file, sent by email. I will fist need to understand what's going on.
chess://
how and where is defined what application will be opened? I'm sure that this mechanism is documented somewhere, but the books I have don't describe it, and Google didn't help me either.
Thank you in advance
Sjakelien
Upvotes: 7
Views: 9963
Reputation: 3518
You have to register the protocol in your app. I've seen a few tutorials before, including this one.
http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
Upvotes: 6
Reputation: 34054
It's called a URL protocol handler. This blog entry details how to implement it. Basically, you need to:
Register the protocol you want (like chess://
). You can do this directly in the Info.plist
file - check out the blog entry for more info.
Handle the request. For this, accept the application: handleOpenURL:
message in your application delegate.
Upvotes: 3