5

I'm using Firebase dynamic links with link shortener and I want to define fallback link for clients beside Android and iOS. Manually constructed dynamic links have parameter ofl that does exactly what I need The link to open on platforms beside Android and iOS. However it seems that this parameter is missing in shortener documentation. Although ofl is mention in the description of link parameter in shortener docs When users open a Dynamic Link on a desktop web browser, they will load this URL (unless the ofl parameter is specified).

Is it possible to somehow add a fallback url for clients beside Android and iOS (e.g. web) to redirect users there instead of link parameter

Kirill Cherepanov
  • 927
  • 1
  • 10
  • 20

2 Answers2

10

By using REST API

POST https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=api_key
Content-Type: application/json

{
  "dynamicLinkInfo": {
    "domainUriPrefix": "https://example.page.link",
    "link": "https://www.example.com/",
    "androidInfo": {
      "androidPackageName": "com.example.android"
    },
    "iosInfo": {
      "iosBundleId": "com.example.ios"
    },
    "desktopInfo": {
      "desktopFallbackLink": "https://www.other-example.com/"
    },
  }
}
lonewolf_911
  • 115
  • 2
  • 8
  • @RyanRomanchuk By reading the python-firebase lib source code – lonewolf_911 Jul 23 '19 at 11:35
  • Thanks, i swear they used to have ofl in the console as well, bet it looks like it has been removed. Can confirm key/value for desktopInfo is working as expected for this REST call though – Ryan Romanchuk Jul 23 '19 at 19:33
  • 1
    OMG you just saved my life, thank you so much. One extra thing I had to do is whitelist the URL I want to use as fallback in Firebase Console, after that everything finally worked. – tudorprodan Apr 23 '21 at 08:42
  • Thanks for your answer! Works for me. It is really strange that Google hasn't included 'desktopInfo' param in their official documentation. – madless Oct 12 '22 at 11:59
3

The simplest way to set fallback url in short dynamic link is to create long link manually and then use sdk to convert it to short one:

val longLink = "$domain/?link=$deepLink&apn=$androidPackage&ibi=$iosPackage&isi=$iosAppStoreId&ofl=$desktopFallbackLink"

FirebaseDynamicLinks
                .getInstance()
                .createDynamicLink()
                .setLongLink(Uri.parse(link))
                .buildShortDynamicLink()
                .addOnSuccessListener {
                    val shortLink = it.shortLink
                    //do something with the link here
                }
anro
  • 1,300
  • 16
  • 30