Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
142
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

@yaboojp

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

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 not register and get more from Qiita?
  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
142
Help us understand the problem. What are the problem?