How to configure dynamic links for a Firebase project?

4.4k Views Asked by At

Since google is shutting down it's url shortening service, I want to move my project to FDL.

I am using the api to shorten the url following this: https://firebase.google.com/docs/dynamic-links/rest#create_a_short_link_from_a_long_link

and I am using Postman to call the api but I keep getting this error.

{
"error": {
    "code": 400,
    "message": "Your project has not configured Dynamic Links. [https://firebase.google.com/docs/dynamic-links/rest#before_you_begin]",
    "status": "INVALID_ARGUMENT"
}
}

I am using the correct api key and the project id.

2

There are 2 best solutions below

8
DasDas On

Had the same issue- and thats the answer i got from the firebase team:

Take note that to be able to view your Dynamic Link domain you'll have to add an app first. If you're using Firebase Dynamic Link as a substitute to Google Shortener, you can create a sample application (dummy app) for your project to proceed creating a Firebase Dynamic Links. Just enter dummy values for the iOS bundle ID or Android package name (ex: “my.dummy.app”) to continue.

then you'll put the id you'll get from it (e.g. https://dedfgu.app.goo.gl) instead of the place holder (https://abc123.app.goo.gl).

Good luck!

0
Prashant Odhavani On

You can try following way

var Url = "https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key={API-Key}";

 $.ajax({
        type: 'POST',
        dataType: 'json',
        url: Url,
        contentType:'application/json',
        data: JSON.stringify({
            "dynamicLinkInfo": {
                "domainUriPrefix": "https://newxpress.page.link",
                "link": {Your-Link},
                "androidInfo": {
                    "androidPackageName": "com.newxpress"
                },
                "iosInfo": {
                    "iosBundleId": "com.newxpress.iosapp"
                }
            }
        }),
        success: function (jsondata) {
            console.log(jsondata);
        },
        error: function (result) {
            console.log(result);
        }
    });