ShortDynamicLink is not generating short link for dynamic links

create dynamic link programmatically
400: cannot shorten a short dynamic link
firebase dynamic links
firebase dynamic links ios
long link is not parsable
firebase dynamic link not opening app android
dynamic link manually
invalid dynamic link firebase

creating a dynamic link

  DynamicLink dynamicLink = FirebaseDynamicLinks.getInstance().createDynamicLink()
            .setLink(Uri.parse("http://shaharapp.in/"))
            .setDynamicLinkDomain("https://cuh8g.app.goo.gl/")
            // Open links with this app on Android
            .setAndroidParameters(new DynamicLink.AndroidParameters.Builder().build())
            // Open links with com.example.ios on iOS
            .buildDynamicLink();

     dynamicLinkUri = dynamicLink.getUri();

after this, i get a long dynamic link. passing this dynamicLinkUri to shortLinkTask

 Task<ShortDynamicLink> shortLinkTask = FirebaseDynamicLinks.getInstance().createDynamicLink()
            .setLongLink(dynamicLinkUri)
            .buildShortDynamicLink();
    shortLinkTask.addOnCompleteListener(new OnCompleteListener<ShortDynamicLink>() {
        @Override
        public void onComplete(@NonNull Task<ShortDynamicLink> task) {
            if (task.isSuccessful()) {


                Uri shortLink = task.getResult().getShortLink();
                link_txt.setText(shortLink.toString());
            }
            else {

                ViewGroup container = (ViewGroup) findViewById(R.id.snackbar_layout);
                Snackbar.make(container, "error", Snackbar.LENGTH_SHORT).show();

            }
        }
    });

This task is not completing, after debugging I got this

com.google.android.gms.common.api.ApiException: 7: Bad Request class com.google.android.gms.common.api.ApiException


What is the long link you are getting? I suggest trying long link and ensure the link works correctly.

Also, append &d=1 to long link. Such link will navigate to debug page with possible errors/warnings displayed.

Looking at your code, one possible reason for failure is format of the domain. See example https://firebase.google.com/docs/dynamic-links/android/create . Domain expected to be string containing only domain, without https scheme:

.setDynamicLinkDomain("abc123.app.goo.gl")

ShortDynamicLink is not generating short link for dynamic links, You can use this REST API to generate short Dynamic Links. information would not be exposed if a short Dynamic Link URL were guessed. Use the Dynamic Link version 16.0.1 to be able to generate a short Dynamic Link: implementation 'com.google.firebase:firebase-core:16.0.1' implementation 'com.google.firebase:firebase-dynamic-links:16.0.1' Stick in using version 16.1.1, create a long link first then try to shorten the long Dynamic Link using this guide.


Make sure your .setDynamicLinkDomain("https://abc123.app.goo.gl") contains "https://"

Create Dynamic Links with the REST API, The created short Dynamic Link will not expire. Repeated calls be shortened. # [Learn # more](https://firebase.google.com/docs/reference/dynamic-links/link-​shortener). This value is generated dynamically and # should never be modified. If your app is set up to receive Dynamic Links, you have already completed these steps and you can skip this section. If you haven't already, add Firebase to your Android project. When you register your app, specify your SHA-1 signing key. If you use App Links, also specify your SHA-256 key.


My Solution when you don't want to downgrade Firebase dependencies

String builtLink = new LinkBuilder().setDomain("example.page.link")
           .setLink("https://www.example.com/someresource")
           .setSd(socialTagDesc)
           .setSt(socialTagTitle)
           .setSi("image link")
           .setApn("android app package")
           .setAmv("android minimum version")
           .setIbi("ios app package")
           .setImv("ios min version")
           .setIsi("ios app id").build();

DynamicLink.Builder builder = FirebaseDynamicLinks.getInstance().createDynamicLink() .setLongLink(Uri.parse(builtLink));

    builder.buildShortDynamicLink()
            .addOnSuccessListener(listener)
            .addOnFailureListener(failureListener);

public static class LinkBuilder{

    private String domain;
    private String link;
    private String apn;
    private String amv;

    private String ibi;
    private String imv;
    private String isi;


    private String st;
    private String sd;
    private String si;

    public String getURLEncode(String input){

        try
        {
            return URLEncoder.encode(input, "UTF-8");
        }
        catch (Exception ex){
            Timber.e(ex);
        }

        return input;
    }


    public LinkBuilder setDomain(String domain) {
        this.domain = domain;
        return this;
    }

    public LinkBuilder setLink(String link) {
        this.link = getURLEncode(link);
        return this;
    }

    public LinkBuilder setApn(String apn) {
        this.apn = apn;
        return this;
    }

    public LinkBuilder setAmv(String amv) {
        this.amv = amv;
        return this;
    }

    public LinkBuilder setIbi(String ibi) {
        this.ibi = ibi;
        return this;
    }

    public LinkBuilder setImv(String imv) {
        this.imv = imv;
        return this;
    }

    public LinkBuilder setIsi(String isi) {
        this.isi = isi;
        return this;
    }

    public LinkBuilder setSt(String st) {
        this.st = getURLEncode(st);
        return this;
    }

    public LinkBuilder setSd(String sd) {
        this.sd = getURLEncode(sd);;
        return this;
    }

    public LinkBuilder setSi(String si) {
        this.si = getURLEncode(si);;
        return this;
    }

    public String build(){
        return String.format("https://%s/?link=%s&apn=%s&amv=%s&ibi=%s&imv=%s&isi=%s&st=%s&sd=%s&si=%s"
                ,domain, link, apn, amv, ibi, imv,isi,st,sd,si);
    }
}

Firebase Dynamic Links Short Links API Reference, Issue When trying to create a short dynamic link on iOS I get an exception from ExceptionsManager. Creating a regular dynamic link works as expected. Android works as expected. const dm = new firebase.links.DynamicLink( I'm not sure if the problem lies in react-native-firebase or firebase-ios-sdk , but  Join GitHub today. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.


Firebase Dynamic Links API . shortLinks, final ShortDynamicLink shortLink = await parameters. queryParameters added to generated ShortDynamicLink are not received in FirebaseDynamicLinks.​instance.onLink You have two ways to generate dynamic links:. To create a short Dynamic Link, pass a previously generated long link to Firebase.DynamicLinks.GetShortLinkAsync or build DynamicLinkComponents in the same way as above. GetShortLinkAsync optionally takes an extra DynamicLinkOptions config parameter with the PathLength property, allowing you to control how the link should be generated.


Failed to create Short Dynamic Link on iOS · Issue #1702 · invertase , Firebase Dynamic Links give you a single link that can send users either to generating both long and short dynamic links to the iOS and Android Firebase public void onSuccess(ShortDynamicLink shortDynamicLink) { // } }); getLink() == null) { // No FDL pending for this app, don't do anything. return; }  If your app did not open from a dynamic link, getInitialLink() will return null. Getting Started # See the example directory for a complete sample app using Google Dynamic Links for Firebase. Issues and feedback # Please file Flutterfire specific issues, bugs, or feature requests in our issue tracker.


[firebase_dynamic_links] queryParameters added to generated , Firebase Creating Dynamic Link with What is Firebase, Features, Android We can create short or long Dynamic Links with the Firebase Dynamic Link Builder API. If we have not already accepted the terms of service, then we have to set a For creating short Dynamic Link, build a Dynamic Link in the same way, and  Google is turning down support for its Google URL Shortener, which launched in 2009. A URL shortening service, it allowed people to shorten and share links easily and also helped to measure online