9

I am trying to use Firebase Dynamic Links in my Android app. I'm confused on one of the parameters used to build deep links.

In the demo app, it calls an api to create a URI to be used as a deep link. As part of that it uses a "app code" as part of the authority method.

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();
}

My questions is, what is the app code and where do I get it?

JustLearningAgain
  • 2,227
  • 4
  • 34
  • 50

1 Answers1

16

Step 1 : include the following in the build gradle and sync the project

compile 'com.google.firebase:firebase-invites:10.0.1'

Step 2 :

Open your project in firebase console and then click on the deep link section and at the top of the page at the top of the page you will see link like https://test123.app.goo.gl/ where the bold section is your app_code

Muhammad Younas
  • 1,543
  • 1
  • 22
  • 32
  • 3
    Thanks for the great answer. Why doesn't Google's docs show this and make it simple? Oh well. Thanks again! – JustLearningAgain Jan 09 '17 at 14:31
  • Well, they do. Exactly like in the answer. – JacksOnF1re Jun 28 '17 at 13:00
  • There is no code generated for a web based app. I need to upgrade the Google URL Shortener to Dynamic Links. Can not find app-code anywhere – andrebruton Apr 17 '18 at 13:32
  • 2
    It might look like https://.page.link instead FYI. Was trying to access "apple-app-site-association" url and had to build like so: https://.page.link/apple-app-site-association – prcbass Aug 16 '18 at 05:58