用于在Firebase for Android中创建网址深层链接的应用代码是什么

Jus*_*ain 9 android deep-linking firebase-dynamic-links

我正在尝试在我的Android应用中使用Firebase动态链接.我对用于构建深层链接的其中一个参数感到困惑.

在演示应用程序中,它调用api来创建用作深层链接的URI.作为其中的一部分,它使用"应用程序代码"作为授权方法的一部分.

public Uri buildDeepLink(@NonNull Uri deepLink, int minVersion, boolean isAd) {
    // Get the unique appcode for this app.
    String appCode = getString(R.string.app_code);

    // Get this app's package name.
    String packageName = getApplicationContext().getPackageName();

    // Build the link with all required parameters
    Uri.Builder builder = new Uri.Builder()
            .scheme("https")
            .authority(appCode + ".app.goo.gl")
            .path("/")
            .appendQueryParameter("link", deepLink.toString())
            .appendQueryParameter("apn", packageName);

    // If the deep link is used in an advertisement, this value must be set to 1.
    if (isAd) {
        builder.appendQueryParameter("ad", "1");
    }

    // Minimum version is optional.
    if (minVersion > 0) {
        builder.appendQueryParameter("amv", Integer.toString(minVersion));
    }

    // Return the completed deep link.
    return builder.build();
}
Run Code Online (Sandbox Code Playgroud)

我的问题是,什么是应用程序代码,我从哪里获得它?

Muh*_*nas 17

第1步:在构建gradle中包含以下内容并同步项目

compile 'com.google.firebase:firebase-invites:10.0.1'
Run Code Online (Sandbox Code Playgroud)

第2步 :

在firebase控制台中打开项目,然后单击深层链接部分和页面顶部 在页面顶部你会看到像https:// test123 .app.goo.gl 这样的链接,其中粗体部分是你的app_code

  • 谢谢你的回答.为什么Google的文档不会显示这一点并简化它?那好吧.再次感谢! (3认同)
  • 它可能看起来像 https://<app_code>.page.link 而不是仅供参考。试图访问“apple-app-site-association”网址并且必须像这样构建:https://<app_code>.page.link/apple-app-site-association (2认同)