microsoft / microsoft/react-native-windows

Deep linking doesn't work if the app isn't running

Open
#6,996 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Needs: Dev Design Partner: AppConsult Workstream: ES Compliance SFI
Dominant language
C++
Stars
17.3k
Forks
1.2k
Avg merge
1d 13h
Merged PRs (30d)
33

Description

Environment

Run the following in your terminal and copy the results here.

  1. npx react-native --version:

4.13.1

  1. npx react-native info:
System:
    OS: Windows 10 10.0.19042
    CPU: (8) x64 Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
    Memory: 1.98 GB / 15.60 GB
  Binaries:
    Node: 12.9.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.10.2 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK: Not Found
    Windows SDK:
      AllowDevelopmentWithoutDevLicense: Enabled
      AllowAllTrustedApps: Enabled
      Versions: 10.0.14393.0, 10.0.15063.0, 10.0.17763.0, 10.0.18362.0, 10.0.19041.0
  IDEs:
    Android Studio: Not Found
    Visual Studio: 16.8.30907.101 (Visual Studio Enterprise 2019), 16.9.30914.41 (Visual Studio Enterprise 2019)
  Languages:
    Java: Not Found
    Python: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1
    react-native: 0.63.2 => 0.63.2
    react-native-windows: ^0.63.0-0 => 0.63.18
  npmGlobalPackages:
    *react-native*: Not Found

Steps To Reproduce

  1. Open the manifest of the application and, in the Declaration tab, register a protocol (for example, foo:)
  2. In the React Native code, reference the Linking module, then add a button which invokes the following function:
const getLinkUrl = async() => {
  const url = await Linking.getInitialURL();
  console.log(url);
}
  1. Close the application
  2. Press Win-R and invoke the application using the protocol you have registered (for example, by typing foo:/details?id=1)

Expected Results

The application starts and, when I press the button, the Linking.getInitialURL() function returns the URL used to invoke the app. Instead, I always get null. The problem happens only if the app isn't running. If it's already running, the app is brought to foreground and the code works.

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

The official sample app in the React Native for Windows repo implements this scenario.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the official sample app in packages/microsoft-reactnative-sampleapps and the Linking.getInitialURL() call described in the issue. Reproduce a protocol launch with the app closed, comparing it with the working case when the app is already running. Done means the app starts from the registered protocol and getInitialURL() returns the invoked URL.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.