开发者

iphone web app to automatically redirect to app [duplicate]

This question already has an answer here: 开发者_如何学运维 Closed 10 years ago.

Possible Duplicate:

Rails: redirect_to 'myapp://' to call iOS app from mobile safari

I am trying to do what Facedialer does when it installs small webapps on your home screen so by clicking them it places a call.

I have my app with its custom url scheme working. If I try writing my custom url from safari it opens my app.

But I can't make it so the web app, when opened, redirects to my custom app. I've tried with window.location.href="myapp://" and a lot of different variants without success.

The only way I have to make it is through META REDIRECT tag. But I need to avoid this solution since I want to discriminate if the user is opening the webapp from the home screen or if it's directly from safari. (using window.navigator.standalone)

Does it make sense? Any advice?

Thanks


Reposting from: Rails: redirect_to 'myapp://' to call iOS app from mobile safari

have you tried window.location?

Sample:

<html><head>
    <script type="text/javascript">
      var userAgent = window.navigator.userAgent;
      if (userAgent.match(/iPad/i) || userAgent.match(/iPhone/i)) {
        window.location = "myiosapp://"
      }
    </script>
  </head>
  <body>
    Some html page
  </body>
</html>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜