1

I am using the dynamic links plugin to create a link, I want that when user clicks on the link if her or she is not on android then he or she must be sent to a website as I have only an android app, but if on android then he must be sent to the app. How to get the desired result? there is no method in the plugin for fallback links for different os. I am creating a dynamic link through code and not in the firebase console.

according to firebase while constructing dynamic links manually we can give Other platform parameters as ofl:

ofl: The link to open on platforms besides Android and iOS. This is useful to specify a different behavior on a desktop, like displaying a full web page of the app content/payload (as specified by param link) with another dynamic link to install the app.

it also has a ifl, i.e if app is not installed on ios:

ifl: The link to open when the app isn't installed. Specify this to do something other than install your app from the App Store when the app isn't installed, such as open the mobile web version of the content, or display a promotional page for your app.

But can't find both ifl and ofl feature in the flutter firebase dynamic links plugin.

2 Answers 2

4

You can manually add ofl (or afl, or ifl) to the long Uri string and use it directly, or even build a short URL from it.

This code creates a DynamicLinkParameters variable parameters using the DynamicLinkParameters() constructor inside an async function, then uses it to create a short link that falls back to https://example.com on desktop:

final DynamicLinkParameters parameters = DynamicLinkParameters(
// constructor arguments
);

final Uri longLink = await parameters.buildUrl();
final ShortDynamicLink shortDynamicLink = await DynamicLinkParameters.shortenUrl(Uri.parse(longLink.toString() + "&ofl=https://example.com"));
final Uri dynamicLinkShortUrl = shortDynamicLink.shortUrl;
Sign up to request clarification or add additional context in comments.

9 Comments

Great you answered what I wanted but, can you show how to use ofl ifl in parameters? When I try there I no such thing in the plugin....but your logic matches with what I thought of doing but couldn't. Please write the complete code you have left the main part.
@Jagadish The thing is, you can't. It is not supported yet in parameters that builds a URL for you. Hence the workaround. They are only available if you build the URL manually. So we get parameters to do all the work for us then add this in the end.
@Jagadish the only supported options in DynamicLinkParameters now are fallback on iOS and fallback on Android, which takes you to a URL instead of a store if the app is not installed on either platforms.
ok if I don't have an Ios app then can I give the fallback link for Ios?
Yes by passing a IosParameters object with fallbackUrl argument to the iosParameters argument in DynamicLinkParameters pub.dev/documentation/firebase_dynamic_links/latest/…
|
0

If i understood your problem correctly, you want to use a link if the user is on android and other if the user is on ios. That can be done importing dart:io and doing something like this:

if (Platform.isAndroid) {
  // add the link to the android page
} else if (Platform.isIOS) {
  // do something else
}

3 Comments

No u didn't understand it, I want that if the link is clicked on any other os such as windows, os except ios, then the link should redirect the user to a website and if android then opens the app. The code which you have given can only be applied inside the app once it receives the link but i don't have an app for ios and windows so the link needs to decide without the help of tghe app.
Oh i understand now, mb. I'll come back with an answer if i figure it out.
yes, i have edited the question, check it out

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.