Facebook URL schemes on a mobile website, open app if its installed, otherwise go to the webpage

后端 未结 1 810
独厮守ぢ
独厮守ぢ 2020-12-14 20:14

I am creating a hybrid desktop/mobile website that all share the same pages, aka I do not have two separate URLs for desktop and mobile. I am trying to get Facebook links t

相关标签:
1条回答
  • 2020-12-14 20:46

    A Simple way would be CSS Media Queries.

    Show the fb:// link for small device widths. and a regular http:// link for larger screen sizes.

    EDIT

    <a href="https://facebook.com/page" class="large-screen">Clicky</a>
    <a href="fb://page/mypage" class="small-screen">Clicky</a>
    

    Then using CSS Media queries hide one of the links depending on the size of the screen.

    UPDATE

    Instead of using CSS a more satisfying user experience can be created with javascript by attempting to open the deep link URL directly after opening the HTTP URL after X seconds in a timeout.

    setTimeout(function () { window.location = "https://www.facebook.com"; }, 25);
    window.location = "fb://";
    

    The HTTP URL will always load, but in the case that deep links are not available, attempting to open one will silently fail, falling back to the web version.

    Source: https://www.quora.com/How-does-Bitlys-Deep-Linking-detect-if-the-user-already-has-the-app-installed

    0 讨论(0)
提交回复
热议问题