简体   繁体   中英

Facebook Share Dialog Deep Linking iOS

I believe I have all of the appropriate deep linking stuff set up on my iOS app. Users can log into our app using the Facebook app if they have it, or Safari if not, and are properly redirected back to our app once that is completed.

I'm having a difficult time trying to achieve the same redirect when users tap on "- Shared via app-name" in the native iOS app. I want to follow the expected flow, where if they don't have the app installed it takes users to the App Store, and if they do it opens my app. Right now, no matter if the app is installed or not, users are directed to the app store.

My setup for my fb app (most values obfuscated for obvious reasons) is as follows:

在此处输入图片说明在此处输入图片说明

NOTE in the above images most of the white space/seemingly empty values are actually there and proper, just deleted from the image for privacy which makes them appear empty , but they aren't.

I had this working on a prior app about 6 months ago or so, but it's my understanding that Facebook has since switched over to App Links , and although I've seemingly read through every bit of documentation I can find on the subject, I can't for the life of me get this to work now.

I'm beginning to wonder if this isn't something we need to configure on the web side of things. Does the webpage that is shared now need to have meta tags embedded that direct users to the appropriate place, ie does the page need to have my app's URL scheme embedded - app-name://, or what?

Is there something special that needs to be done to redirect from a share on the Facebook iOS app, that is different from redirecting from login on the Facebook iOS app?

Facebook documentation is very incomplete.. I had to scrap some info from this website: http://applinks.org/documentation/

In my apps I share all the stories with a link like "example.com/share.php" and the code in my share.php file is the following:

<?php
    require 'Mobile_Detect.php'; //you need to download this
    $detect = new Mobile_Detect;

    //if user is accessing the "shared history" from the facebook website
    //it should be redirected to the website, not allowing him to browse this
    //page, as it is empty.
    //
    //the regex avoids the redirect for facebook crawler
    if (!preg_match('%facebookexternalhit/1.*%si', $_SERVER["HTTP_USER_AGENT"])) {
        if (!$detect->isiOS() && !$detect->isAndroidOS()) {
            header("Location: http://www.example.com/");
            die();
        }
    }

?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>App Share Page</title>

    <!-- This disables the intermediate web view in mobile, jumping straigt to the app -->
    <meta property="al:web:should_fallback" content="false">

    <!-- Android -->
    <meta property="al:android:url" content="customschemaurl://fromShare">
    <meta property="al:android:package" content="com.mycompany.myappbundleid">
    <meta property="al:android:app_name" content="App name">

    <!-- iOS -->
    <meta property="al:ios:url" content="customschemaurl://fromShare" />
    <meta property="al:ios:app_store_id" content="0000000" /> <!-- itunes connect app id, not bundle id -->
    <meta property="al:ios:app_name" content="App name" />

    <!-- OG Share (url shared) -->
    <meta property="og:title" content="some share title"/>
    <meta property="og:url" content="http://www.example.com/share.php"/>
    <meta property="og:image" content="http://www.example.com/byb-logo.png"/>
    <meta property="og:site_name" content="App name"/>
    <meta property="og:description"
          content="some description text"/>

</head>
<body>
</body>
</html>

This simple webpage detects if it's android, or iphone and launch the app, if it is a webbrowser (not mobile) it will redirect to your website (maybe download page if you have a multiplataform app like me) and allows facebook crawler (not mobile) to access the needed information to correct call the app.

Hope it helps..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM