20

Is it possible to open native iOS app, e.g. calendar or notes, from an HTML link which is in website? I tried to find an example but I couldn't. I ran into these URL schemes but I don't know how to use them and what's the URL scheme for calendar or notes. Is it possible just to do something like this:

<a href="calendar://something here?">Click me!</a> 

Is it possible to do it only with HTML or is JavaScript needed?

nqw1
  • 979
  • 3
  • 11
  • 16

3 Answers3

16

If you're looking for the URL Schema, iPhone Calendar is: CALSHOW:

Cro
  • 161
  • 1
  • 2
8

Calendar and Notes do not have URL schemes. Apple provides a reference for those of their apps that do use URL schemes here:

https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/Introduction/Introduction.html

Cœur
  • 37,241
  • 25
  • 195
  • 267
Andrew
  • 97
  • 1
  • 1
  • 3
    +1 for the relevant official documentation, but latecomers should see @Cro's answer below for *unsupported, but working* schemes. – mklement0 Nov 15 '13 at 00:12
7

Yes you can very well possible to do that. You're right in placing the link like this:

<a href="calendar://">Click me!</a>

Now go to your iOS app's info.plist file. In that add the following tags:

<key>CFBundleURLTypes</key>
<array>
<dict>
    <key>CFBundleURLName</key>
    <string>com.companyname.appname</string>
    <key>CFBundleURLSchemes</key>
    <array>
        <string>calendar</string>
    </array>
</dict>
</array>

Save the plist file and exit it. After this when you open the web page in Safari browser of your iOS device and click on the link, your iOS app will invoke. I hope it helps!

Dip Dhingani
  • 2,499
  • 2
  • 20
  • 18
  • 1
    Thanks for your help! What if I don't have any app of my own? If I'm just creating a web page and I would like to have a link which would open the user's calendar on their iPhone or iPad. – nqw1 Oct 05 '11 at 09:36
  • 1
    Unfortunately then this technique wont be possible, because inserting the aforementioned key in info.plist file of the app you wish to invoke wont be possible (as Calendar is default iPhone app). You'll require the hook for Calendar app which unfortunately I am not aware of. – Dip Dhingani Oct 05 '11 at 09:44
  • I tried with my iOS app but didn't succeed. I added those tags into my info.plist file and they showed up correctly in Xcode like [here](http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html). I made HTML file with that tag. I builded the app to my iPad but when I click the link, it says "no internet connection" which comes sometimes if I have some HTML file missing. In this case it doesn't seem to understand my href="calendar://". Where could be the problem? – nqw1 Oct 05 '11 at 10:23
  • The tutorial is perfect. I hope you were testing this using your iPhone simulator's Safari browser only and no other browser, because this won't work in your desktop browser. If you're using your simulator's browser then I don't see a reason why it shouldn't work for you. – Dip Dhingani Oct 05 '11 at 10:33
  • I tested it on iPad simulator and on iPad. I have WoodWing's digital magazine template in Xcode which I use to build up the app. HTML page is embedded on the digital magazine's page and I guess it uses mobile Safari because all the webkit stuff works on it. Well, I guess I just have to look more carefully did I do something wrong. – nqw1 Oct 05 '11 at 10:45
  • I found [this](http://stackoverflow.com/questions/1341627/is-there-an-iphone-url-shortcut-for-calendar) but it seems that native calendar application doesn't have its own custom URL scheme. It doesn't work with calendar scheme so is there another scheme for it? Or is there some good workaround to call calendar? – nqw1 Oct 10 '11 at 08:38
  • @DipDhingani thanks for this informative post. Additional question - what happens if the user does not have the app installed but the app is on the app store? Will it redirect the user to the app store or just fail to load? I just tried it out with my non-published app. It works great but not if the app is uninstalled, then it just fails. What's a good workaround for the fail if apple doesn't automatically send it to the app store? Thanks! – Sunnyside Productions Jan 09 '15 at 19:45