简体   繁体   English

Facebook分享对话框深层链接iOS

[英]Facebook Share Dialog Deep Linking iOS

I believe I have all of the appropriate deep linking stuff set up on my iOS app. 我相信我在iOS应用程序上设置了所有适当的深层链接。 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. 用户可以使用Facebook应用程序(如果没有)登录到我们的应用程序,如果没有,则可以使用Safari登录,并在完成后正确地重定向回我们的应用程序。

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. 当用户在本机iOS应用程序中点击“-通过应用程序名称共享”时,我很难尝试实现相同的重定向。 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. 我想遵循预期的流程,如果他们没有安装应用程序,它将把用户带到App Store,如果他们这样做,则会打开我的应用程序。 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: 我的fb应用程序的设置(出于显而易见的原因,大多数值都被混淆了)如下:

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

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. 我大约在6个月前左右就在以前的应用程序上进行过这项工作,但是据我了解,Facebook自此已切换到App Links ,尽管我似乎已经阅读了有关该主题的所有文档,但我可以为了我的一生,现在就让它开始工作。

I'm beginning to wonder if this isn't something we need to configure on the web side of things. 我开始怀疑这是否不是我们需要在Web端配置的东西。 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? 现在共享的网页是否需要嵌入可将用户定向到适当位置的元标记,即该页面是否需要嵌入我的应用程序的URL方案-app-name://或什么?

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 iOS应用程序上的共享重定向需要做些什么与从iOS iOS应用程序登录的重定向不同吗?

Facebook documentation is very incomplete.. I had to scrap some info from this website: http://applinks.org/documentation/ Facebook文档非常不完整。.我不得不从该网站上删除一些信息: 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: 在我的应用中,我通过“ example.com/share.php”之类的链接共享所有故事,并且share.php文件中的代码如下:

<?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. 这个简单的网页会检测它是Android还是iphone并启动应用程序,如果它是Web浏览器(非移动版),它将重定向到您的网站(如果您有像我这样的多平台应用程序,则可以下载页面),并允许Facebook搜寻器(非移动版) )以访问所需信息以正确调用该应用。

Hope it helps.. 希望能帮助到你..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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