Kirill Cherepanov
Kirill Cherepanov

Reputation: 975

Firebase short links fallback link

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

Upvotes: 5

Views: 3518

Answers (2)

anro
anro

Reputation: 1406

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
                }

Upvotes: 3

lonewolf_911
lonewolf_911

Reputation: 115

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/"
    },
  }
}

Upvotes: 10

Related Questions