firebasefirebase-dynamic-linksshort-url

Create Firebase dynamic link with 2 params


I am creating a new dynamic link for our site. I'm manually creating them thru our NodeJs backend apis using "https://firebasedynamiclinks.googleapis.com/v1/shortLinks". We already have a shortUrl that is created from "https://example.com/v=5e4eafa80a863710813bc67b?s=ABCDEF" and it works fine.

Now I need to create one with a second param: "https://example.com/reset?email=test@email.com&token=123456"

The first one (email) is included in the shortUrl, but the second param (token) is removed. Do I need to config something to include the second one?


Solution

  • I received an answer from Firebase Slack support

    I think your problem arises because Google Servers expects the data for the deep link it sends to your app to be in only one specific name/value pair. When you create a second parameter using the & the server parsing the dynamic link, is expecting a new name/value pair and thus does not see or even know what to do with the data you sent. It never makes it to your server.

    I was thinking about this problem the other day before I read your post. Let's use the manual construction link as an example found at https://firebase.google.com/docs/dynamic-links/create-manually

    Here is an example dynamic link created manually: https://your_subdomain.page.link/?link=your_deep_link&apn=package_name[&amv=minimum_version][&afl=fallback_link] The part you are interested in is ?link=your_deep_link. If you try to add another name/value pair to that deep your_deep_link by doing something like ?link=email=test@email.com&token=018265, that ampersand (&) before token is probably causing the Google servers to read it as a separate name/value pair that does not belong to your_deep_link.

    In the example I posted above, you can see the ampersand after your_deep_link is supplying a new name/value pair that the Google Servers parse to use.

    Your language should have some equivalent to PHP explode https://www.php.net/manual/en/function.explode.php or C# string split https://learn.microsoft.com/en-us/dotnet/csharp/how-to/parse-strings-using-split

    I would construct a string that used a colon (:) (or some other character that I'm sure is not part of my regular deep-link, as the delimiter so your deep-link would look like ?link=https://your.domain/reset?email=test@email.com:018265"

    Once you get the link, pull the data from it using the explode equivalent of your language.