Help us understand the problem. What is going on with this article?

iOS/Androidのブラウザ開いた時に、URLスキームが存在すればアプリ・存在しなければマーケットを開く方法

More than 1 year has passed since last update.

Androidだとそれ用の書き方があるからいいんだけど、iOSだとJSでやるしかなさげ。

Androidの場合

"intent://hoge.com#Intent;scheme=get-hoge;package=com.hoge.activity;end"

iOSの場合

<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="utf-8">
  <title>iOSで開いた時に、URLスキームが存在すればアプリを開く、存在しなければAppStoreを開く</title>

  <script type="text/javascript">
    $(function(){
      var userAgent = navigator.userAgent.toLowerCase();
      if (userAgent.search(/iphone|ipad|ipod/) > -1) {
        // Launch myapp via URL scheme
        launch_frame.location.href= "myapp://";

        setTimeout(function(){
          // Open App DL page in iTunes Store
          location.href= "itmss://itunes.apple.com/us/app/myapp/id99999999?ls=1&mt=8";
        } , 500);
      }
    });
  </script>
</head> 
<body>
  <div style="width:0; height:0; overflow:hidden;">
  <iframe id="launch_frame" name="launch_frame">
  </iframe>
  </div>
</body> 
</html>
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away