iOS and Android Shared HTTP Deep Linking?

一曲冷凌霜 提交于 2019-12-04 00:35:59

问题


I am trying to launch my native app through a URL (shared via email etc). It seems that Android only responds to HTTP deep link URLs (e.g., http://myapp.com/stuff), and that iOS only responds to non-HTTP custom deep link URLs (e.g., myapp://stuff). Has anyone found a single solution to enable both OS's to open the same URL?

Also, is it possible for iOS to use HTTP deep link URLs? Similar to how http://youtu.be will open the native iOS app. Facebook does this too.

Thanks! :)


回答1:


This article can be usefull "URL schemes for iOS and Android": http://fokkezb.nl/2013/09/20/url-schemes-for-ios-and-android-2/

Edited: The main idea to send user a link to a website. Using the platform detection on server we can return correct link:

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;';
    }
}


来源:https://stackoverflow.com/questions/29435029/ios-and-android-shared-http-deep-linking

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!