Launch iPhone app from html onload

html, ios, ios5, iphone, javascript

Solution

Make a PHP page like this:

<?php
 header("Location: MyApp://somestring;")(
?>
<html>
 <head>
  <meta http-equiv="Refresh" content="0; MyApp://somestring" />
  <title>Opening App...</title>
  <script>
   function openApp() {
    window.location.href = "MyApp://somestring";
   }
  </script>
 </head>
 <body onload="openApp();">
  <a href="MyApp://somestring">Click here if app doesn't open...</a>
 </body>
</html>

Problem

I have created an iPad application. I want to launch it from safari. With URL Schema, it's done successfully. From my application, I want to send a link. Which on click should open my app. The mail which I have sent contains matter in the following way CLICK HERE TO LAUNCH APP Which is an anchor tag whose href = "MyApp://someString". But when I send this as mail, on iPad configured mail, link is working fine but in browsers it's not working. Then I came to know that Yahoo, Gmail will deactivate links other than starting with `http://` Now, I want to open my app with URL schema `MyApp://` with HTML Onload similar to opening iTunes in our PC when itunes.apple.com is opened With `windows.open('MyApp://')`, in the `onload()` function also, my app is not launching. How to do that? How to launch my app when html is loading?

Original source