Search code examples
.netfirebase-dynamic-links

Firebase dynamic link works perfectly if open directly but doesn't work if opens from browser redirect


i have flutter app and asp.net core backend My app authorization process looks like: app -> browser (login/pass) -> backend which generates token -> get method which redirects to dynamic link with token (this is government resources , so authorization complicated) as i mentioned earlier dynamic link works perfectly if open it directly, but it doesn't work if try open it from browser redirect (it opens play market empty page, or redirects to domain) My asp.net core link generation and redirect code looks like:

var fireBaseLink = new FireBaseLink
        {


            DynamicLinkInfo = new DynamicLinkInfo
            {
                DomainUriPrefix = "domain",
                Link = $"site/?token={"3123131"}",
                IosInfo = new IosInfo()
                {
                    IosBundleId = "package"
                },
                AndroidInfo = new AndroidInfo()
                {
                    AndroidPackageName = "package"
                },
            }
        };

        var json = JsonConvert.SerializeObject(fireBaseLink);
        var data = new StringContent(json, Encoding.UTF8, "application/json");

        var url = $"https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key={firebase token}";
        using var client = new HttpClient();

        var response = await client.PostAsync(url, data);

        var result = await response.Content.ReadAsStringAsync();
        FireBaseDynamicLinkResult dynamicLink = JsonConvert.DeserializeObject<FireBaseDynamicLinkResult>(result);
        return Redirect(dynamicLink.ShortLink);

Any advices please... I tested on some phones: some opens app normally, but some phones open empty play market page, but if it i tries few times , on second and above it starts open app. But after sometime it doesn't work again. I think it's related to package name, but if reinstall app, it works same..


Solution

  • I solved this issue by using this package I know , it isn't complete solution, but at least, i reached my goal