iOS和Android共享HTTP深度链接?

时间:2015-04-03 15:24:12

标签: android ios deep-linking

我正在尝试通过网址启动我的原生应用(通过电子邮件等共享)。 Android似乎只响应HTTP深层链接网址(例如http://myapp.com/stuff),并且iOS仅响应非HTTP自定义深层链接网址(例如,myapp:// stuff)。有没有人找到一个解决方案来让两个操作系统打开相同的URL?

此外,iOS是否可以使用HTTP深层链接URL?与http://youtu.be将如何打开原生iOS应用程序类似。 Facebook也是这样做的。

谢谢! :)

1 个答案:

答案 0 :(得分:1)

这篇文章对iOS和Android":http://fokkezb.nl/2013/09/20/url-schemes-for-ios-and-android-2/

的网址方案非常有用

编辑: 向用户发送链接到网站的主要想法。使用服务器上的平台检测我们可以返回正确的链接:

function open() {

    // If it's not an universal app, use IS_IPAD or IS_IPHONE
    if (IS_IOS) {
        window.location = "myapp://view?id=123";

        setTimeout(function() {

            // If the user is still here, open the App Store
            if (!document.webkitHidden) {

                // Replace the Apple ID following '/id'
                window.location = 'http://itunes.apple.com/app/id1234567';
            }
        }, 25);

    } else if (IS_ANDROID) {

        // Instead of using the actual URL scheme, use 'intent://' for better UX
        window.location = 'intent://view?id=123#Intent;package=my.app.id;scheme=myapp;launchFlags=268435456;end;';
    }
}