将自定义URL方案转换为QR码(IOS)

时间:2017-08-02 03:15:04

标签: ios qr-code url-scheme

我的问题是如何将自定义网址转换为可以打开应用的二维码。

假设我有一个自定义网址(myScheme://)。如果我在手机的浏览器上输入它,它可以工作。 但是,如果我只是通过一些在线qr代码生成器进行转换,那么qr代码阅读器不会在浏览器中打开url而只返回纯文本。

这是否意味着我需要建立一个自己的QR码阅读器来处理它?<​​/ p>

1 个答案:

答案 0 :(得分:0)

我认为这取决于QR码阅读器应用程序。在我的情况下,我有一个自定义网址(itms-services://?action=download-manifest&url=xxxQR Reader for iPhone。但有些客户表示:&#34;我无法安装该应用。 QR只是打开Safari。&#34;。有很多QR阅读器应用程序,我们不知道使用哪一个。

但您可以使用自己的网站this

<!doctype html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0, maximum-scale=1.0" />
    <title>Site Name</title>
    <style>@media screen and (max-device-width:480px){body{-webkit-text-size-adjust:none}}</style>

    <!-- implement javascript on web page that first first tries to open the deep link
        1. if user has app installed, then they would be redirected to open the app to specified screen
        2. if user doesn't have app installed, then their browser wouldn't recognize the URL scheme
        and app wouldn't open since it's not installed. In 1 second (1000 milliseconds) user is redirected
        to download app from app store.
     -->
    <script>
    window.onload = function() {
    <!-- Deep link URL for existing users with app already installed on their device -->
        window.location = 'yourapp://app.com/?screen=xxxxx';
    <!-- Download URL (MAT link) for new users to download the app -->
        setTimeout("window.location = 'http://hastrk.com/serve?action=click&publisher_id=1&site_id=2';", 1000);
    }
    </script>
</head>
<body>

    <!-- button to Download App for new app users -->
    <form action="http://hastrk.com/serve?action=click&publisher_id=1&site_id=2" target="_blank">
        <input type="submit" value="Download" />
    </form>

    <!-- button to Open App to specific screen for existing app users -->
    <form action="yourapp://app.com/?screen=xxxxx" target="_blank">
        <input type="submit" value="Open App" />
    </form>

</body>
</html>

然后你应该用网站网址生成QR。它将在Safari中打开,并将重定向您的应用程序。 (我希望如此。)