Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linking.getInitialUrl never returns #26947

Closed
Dellybro opened this issue Oct 21, 2019 · 10 comments
Closed

Linking.getInitialUrl never returns #26947

Dellybro opened this issue Oct 21, 2019 · 10 comments
Labels
API: Linking Bug Resolution: Locked This issue was locked by the bot.

Comments

@Dellybro
Copy link

Dellybro commented Oct 21, 2019

System:
OS: macOS Mojave 10.14.6
CPU: (8) x64 Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
Memory: 30.13 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.15.1 - /usr/local/bin/node
npm: 6.9.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
IDEs:
Android Studio: 3.4 AI-183.5429.30.34.5452501
Xcode: 11.0/11A420a - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.2 => 0.61.2
npmGlobalPackages:
react-native-cli: 2.0.1

React Native version:

0.61.2

Steps To Reproduce

  1. On simulator / emulator / live iOS or Android phone run the command await Linking.getInitialUrl().

this command never returns and just hands

Describe what you expected to happen:

I expected an event to be returned. This worked in previous versions. This is the 4th app i've updated to v61.2 and had this issue on.

Snack, code example, screenshot, or link to a repository:

async function someFn() {
     let event = await Linking.getInitialURL()
     // Next line of code never runs
     ....
}

Edit: I've confirmed that this only happens when using async await. Using .then.catch the event seems to return as normal.

@JulianKingman
Copy link

Try putting a catch on there to see if you're getting an error.

async function someFn() {
     let event = await Linking.getInitialURL().catch(err => console.log(err))
     // Next line of code never runs
     ....
}

@musemind
Copy link

musemind commented Dec 31, 2019

We have the same problem on Android after updating to Expo SDK 36 (React Native 0.61). The Promise from Linking.getInitialURL() is not resolving. This happens at least in development. After a fast refresh, the promise resolves.

We prevent the app with a timeout from being stuck in the initialization process:

const getInitialUrl = (): Promise<string | null> => {
  return new Promise((resolve, reject) => {
    const timeout: number = setTimeout(() => {
      resolve(null)
    }, 2000)
    Linking.getInitialURL()
      .then(url => resolve(url))
      .catch(err => reject(err))
      .finally(() => clearTimeout(timeout))
  })
}

@krishnakumarrk
Copy link

@musemind I am getting '_reactNative.Linking.getInitialURL(...).then(...).catch(...).finally is not a function'. Any idea?

@joaocac
Copy link

joaocac commented Jan 28, 2020

Hi,

my team has discovered that debug mode is breaking something since we have the correct and expected behavior in a real iOS device.

Unfortunately, this is not true for android. In a real device, without debug, we are experiencing a return of null value when calling getInitialUrl for cold-start (app is not running).

I hope this can help, and if someone figures how to make it work for android, please post.

System:
OS: macOS 10.15.2
CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
Memory: 68.70 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 11.9.0 - /usr/local/bin/node
npm: 6.5.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
IDEs:
Xcode: 11.3/11C29 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.2 => 0.61.2
npmGlobalPackages:
react-native-cli: 2.0.1

@bsonmez
Copy link

bsonmez commented Jan 31, 2020

We have the same issue. It does not even catch the error or returns anything on Android devices only. Somehow it perfectly works on iOS

@satya164
Copy link
Contributor

Duplicate of #25675

@stale
Copy link

stale bot commented May 15, 2020

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label May 15, 2020
@aymkin
Copy link

aymkin commented May 18, 2020

Hi,

my team has discovered that debug mode is breaking something since we have the correct and expected behavior in a real iOS device.

Unfortunately, this is not true for android. In a real device, without debug, we are experiencing a return of null value when calling getInitialUrl for cold-start (app is not running).

I hope this can help, and if someone figures how to make it work for android, please post.

System:
OS: macOS 10.15.2
CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
Memory: 68.70 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 11.9.0 - /usr/local/bin/node
npm: 6.5.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
IDEs:
Xcode: 11.3/11C29 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.2 => 0.61.2
npmGlobalPackages:
react-native-cli: 2.0.1

Thx a lot for the idea! the app behaves differently if you call Linking. getInitialUrl in debugging mode

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label May 18, 2020
@nastaransamui
Copy link

still happen in "react-native": "0.63.0", and it's always "null"

@satya164
Copy link
Contributor

Closing as duplicate of #25675

@facebook facebook locked as resolved and limited conversation to collaborators Oct 2, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
API: Linking Bug Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

11 participants