Linking.parse(URL) doesn't work properly

Please provide the following:

  1. SDK Version: 36.0.0.
  2. Platforms(Android/iOS/web/all): all

I’m attempting to use Linking in my managed app. The goal is to have a QR-link (including params) opening the app that then trigger actions in the app. Even if the user have to install the app from appstore first I want the params be kept alive and triggered when app will run. First of all, can Linking do the job?

What I have tried so far is to create a link within the app:

let redirectUrl = Linking.makeUrl("qr", { hello: "world" });
console.log(redirectUrl) // exp://

I register eventlisteners and console logg using the callback _handleUrl:

React.useEffect(() => {
    Linking.addEventListener("url", _handleUrl);
  }, []);

const _handleUrl = url => {
/* Object {
  "hostname": null,
  "path": "[object Object]",
  "queryParams": Object {},
  "scheme": null,

So when I parse the url something weird happens. It doesn’t recognize the params and percieves the path as an object? From the initial log the URL clearly contains both a path and params: exp://–/qr?hello=world. What am I doing wrong?

Hm, I just put together this snack and didn’t see the behavior you’re talking about. Maybe you can edit it to reproduce the weirdness?

Also, not sure if you already have but reading this guide might help. I have a feeling you’re looking for Linking.getInitialURL, since the app will not have been opened before

Thank you for the response! I tried what you did and parsed the URL directly after making it (insted of parsing it in another file) and that worked fine! So I realised something must be wrong with my eventlister callback, turns out “url” was actually an object with an key “url”:

const _handleUrl = url => {
   console.log(Linking.parse(url.url)); // this worked better

I think I need both getInitialURL and eventlisteners in case the app is installed&open and the QR is scanned from an external app. Actuall My scenario that I am not sure that Linking will cover for:

  1. User scans the QR with external app
  2. Redirects to website which runs a script
  3. Script identifies that they do not have the app so it redirects to store/play
  4. After that the app is installed, getInitialURL is run and actions within the app are run according to the url and its params.

Do you know if this “initial url” will survive the user going through installing the app through appstore/Google play? I don’t want the user to have to scan the QR code twice.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.