2

我是具有配套网站的基本电子商务应用程序的开发人员。我想尝试应用链接,以将我的用户从我的网站引导到我的移动应用上的某些屏幕。

applinks 网站教程提供了以下示例,作为将应用链接引入特定应用的一种方式。

如果我想“链接”到每个应用程序中的一个屏幕,这是可能的。但是,如果我想链接到多个屏幕,我该怎么办?

我希望网站能够将用户引导到主屏幕、搜索屏幕以及支付屏幕。有没有一种有效的方法来做到这一点?我必须在不同的页面上添加不同的应用程序链接吗?

编辑

感谢亚历克斯的回复。我已尝试按照您的 Android 应用程序指南进行操作,但它似乎不起作用。每当我在 Android Chrome 浏览器上打开我网站的 URL 时,什么都没有发生。我想要自动重定向到我的应用程序。这是我的代码片段(名称和网址的化名)。

网站:

     <meta property="al:android:url" content="ecommerceapp://dlogsman" />
     <meta property="al:android:app_name" content="ECommerceApp" />
     <meta property="al:android:package" content="com.ecommerce.app" />
     <meta property="al:web:url" content="http://ecommerce.com/~dlogsman" />

安卓清单:

   <activity
        android:name="com.ecommerce.app.App"
        android:label="@string/app_name_ecommerce">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
        <intent-filter>
            <data android:scheme="ecommerceapp" android:host="open" />
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter>
    </activity>

然后我的 onStart 方法完全按照您的建议处理意图。有什么建议么??再次感谢您的时间。

4

1 回答 1

0

作为提醒,我在使用 Branch 链接工具 ( branch.io ),它有助于简化包括 Facebook 在内的所有渠道的深度链接(并简化 AppLinks 的噩梦)

App Links 所做的只是告诉 Facebook 机器人如何将相应的网站 URL 映射到您的本地应用程序 URL。它只是添加到站点标题的一组元标记,以便告诉 Facebook 在安装应用程序时调用哪个应用程序 URL。唯一的实际链接是您的网站链接。因此,您现有电子商务网站的给定页面上只能有一组 AppLink。为了在您的应用程序中使用 AppLinks 到不同的页面,您实际上需要有不同的 Web URL。所以,你需要有一个:

  • http://yourecommercesite.com/home并添加元标记yourecommerceapp://home
  • http://yourecommercesite.com/search并添加元标记yourecommerceapp://search
  • http://yourecommercesite.com/payment并添加元标记yourecommerceapp://payment

然后,您需要构建您的应用程序以进行深度链接。如果您还没有这样做,以下是如何设置它并在 iOS 中接收 URL 路径:

  1. 将 yourrecommerceapp:// 的 URI 方案添加到 PLIST 文件

plist uri

  1. 编写代码接收URI路径
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    if ([[url path] hasSuffix:@"home"]) {
        // load the home view controller
    } else if ([[url path] hasSuffix:@"search"]) {
        // load the search view controller
    } else if ([[url path] hasSuffix:@"payment"]) {
        // load the payment view controller
    }
    return YES;
}

在 Android 中是这样的:

  1. 设置应用清单以接收来自 yourrecommercesite:// 的意图。您只需要在<activity></activity>标签中添加它
<intent-filter>
    <data android:scheme="yourecommercesite"/>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
  1. 在接收到intent的Activity的onStart中,添加如下代码:
@Override
protected void onStart() {
    super.onStart();

    if (this.getIntent().getData() != null) {
        if (this.getIntent().getData().getPath().equals("home")) {
            // load the home activity
        } else if (this.getIntent().getData().getPath().equals("search")) {
            // load the search activity
        } else if (this.getIntent().getData().getPath().equals("payment")) {
            // load the payment activity
        }
    }

}
于 2015-07-20T00:15:46.623 回答