Hello, one and all,
I agree this is a bit uncanny, but I need to know the redirect URL of the dynamic link of my own app. The purpose is simple, we have an in-app QR code scanner and upon scanning a QR code containing a dynamic link of our own app, I want to open the corresponding details panel based on the QR-code scanner's result. Now the QR code scanner's result, in this case, will the dynamic link of my app, and I want the redirect URL of the dynamic link to know and open the corresponding panel directly.
I thought of doing a web services call to know the redirect URL using cURL and PHP. Now, this approach works for other URLs but fails for firebase dynamic links somehow. I tried below functions to get the redirect URLs using a PHP web service:
function get_redirect_target($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$headers = curl_exec($ch);
curl_close($ch);
if (preg_match('/^Location: (.+)$/im', $headers, $matches))
return trim($matches[1]);
return $url;
}
function get_redirect_final_target($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$headers = curl_exec($ch);
$target = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
curl_close($ch);
return $target;
}
Now, I scraped through the firebase documentation and couldn't get much help there. I also looked around for some other ways of getting the redirect URL but couldn't get anything to work with the dynamic links created from the firebase. I sincerely hope this is possible.
Could anybody from the firebase team/community please guide me on how to do this? Also, kindly let me know I am missing something here. Guys, please help!
Regards,
Sanket.