通过邮件链接打开iOS应用

Nan*_*rve 1 ios

当用户按下邮件链接时,如何在iPhone中打开已安装的应用程序;如果未安装,则如何重定向至应用程序商店链接?

Tej*_*hna 5

将以下行添加到您的plist文件中:(DemoTest是我的自定义URL架构)

<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLName</key>
            <string>DemoTest</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>DemoTest</string>
            </array>
        </dict>
    </array>
Run Code Online (Sandbox Code Playgroud)

然后尝试从浏览器URL打开DemoTest://,它将要求您打开已安装的应用程序。

在此处输入图片说明

HTML代码:

<html>
    <body>
        <script type="text/javascript">
            window.onload = function() {
                // Deep link to your app goes here
                document.getElementById("l").src = "DemoTest://";

                setTimeout(function() {
                    // Link to the App Store should go here -- only fires if deep link fails                
                    window.location = "https://itunes.apple.com/us/app/my.app/id123456789?ls=1&mt=8";
                }, 500);
            };
        </script>
        <iframe id="l" width="1" height="1" style="visibility:hidden"></iframe>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)