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
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With