相关疑难解决方法(0)

适用于IOS和Android应用程序的Deeplink解决方案适用于Facebook

有太多深层链接(通用链接或应用链接)教程.但其中大多数都展示了如何在Android或IOS应用中启用它.此外还有付费云解决方案,但它们提供了许多功能.但是我在现实生活中面临三个主要问题:

  1. 某些浏览器不允许App Links工作.例如,您可以将http://example.com配置为在应用程序中捕获,但如果用户通过Facebook应用程序单击此链接则不会处理,并且Facebook浏览器会显示该网站.
  2. 没有独特的标准解决方案来处理Android和IOS应用程序的链接.
  3. 如果应用程序未安装在移动设备上且用户单击App Link,则无法提供实用的解决方案.

我写了这个Q&A,这是我学习的结果(花了太多时间),以便有一个独特的,适用于所有案例的解决方案.

代码来自我的工作解决方案,但我删除了一些部分只是为了表明这个想法.如果存在一些编译问题,请按照算法编写自己的代码

这是解决方案,即使你知道一些步骤也要一步一步,因为代码中有技巧.还有一些解释在代码部分的注释行中,请阅读它们.

示例是使用最终的参数处理Android和IOS应用程序的深层链接http://example.com/v/,例如http://example.com/v/id-of-user?key=value.

1.配置Android

1.1将活动信息添加到AndroidManifest.xml文件中:

<activity
android:name=".appLinkHandlerActivity">

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data
        android:host="example.com"
        android:pathPrefix="/v/"
        android:scheme="http" />
</intent-filter>

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

<!—this intent is needed to handle links to myapp://share, I will explain later why we need it -->
    <data
        android:host="share"
        android:scheme="myapp" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)

1.2创建名为appLinkHandlerActivity的活动,该活动将处理单击的链接

    public class appLinkHandlerActivity extends AppCompatActivity {


    /* assume that user is clicked http://example.com/v/my-user-id   
    actCode will be …
Run Code Online (Sandbox Code Playgroud)

facebook deep-linking applinks ios-universal-links deeplink

8
推荐指数
0
解决办法
2120
查看次数