question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deep linking in Android not working if the app is in the background

See original GitHub issue

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

Environment: OS: macOS High Sierra 10.13.2 Node: 9.0.0 Yarn: 1.3.2 npm: 5.5.1 Watchman: 4.9.0 Xcode: Xcode 9.2 Build version 9C40b Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed) react: 16.2.0 => 16.2.0 react-native: 0.52.1 => 0.52.1

Target Platform: Android 4.0.0 or higher. iOS works fine.

Steps to Reproduce

  1. Add Linking.addEventListener to componentDidMount, with alert callback, just to check if it works;
  2. Put the app in background;
  3. Open a deep link.

Expected Behavior

Fire the callback handler specified in the addEventListener function.

Actual Behavior

The callback function simply doesn’t get fired. The getInitialURL() works as expected (alerts the correct URL in this case, when the app is launched from the deep link click). This issue happens only on iOS, Android works fine.

It looks like that the callback event listener function is not getting fired.

Reproducible Demo

AndroidManifest.xml

<activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:launchMode="singleTask"
>

index.js

import React, { PureComponent, AppRegistry, View, Linking } from 'react-native'

class Root extends PureComponent {
  componentDidMount() {
    Linking.getInitialURL().then(alert)
    Linking.addEventListener('url', alert)
  }

  render() {
    return (
      <View />
    )
  }
}

AppRegistry.registerComponent('linkingtestapp', () => Root)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

1reaction
Udbhav12commented, Aug 5, 2018

I have the same issue in iOS @GopiKrishna10 - How did you solve this for iOS ?

0reactions
tajammul1996commented, Jun 7, 2018

Did anyone found the solution for this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deep link into an app while the app is already running in the ...
The issue I am having is the app is already open in the background and then the user clicks a deep link to...
Read more >
[Android] Deep linking not working when app is in background ...
Enable developer options on your Android device ; Enable Don't keep activities in developer options; Open the app; Tap Home button on your...
Read more >
Your Deep Links Might Be Broken: Web Intents and Android 12
Get ahead of the behavior changes in the latest Android 12 update by fixing deep links with web intents in this guide.
Read more >
Deep link mobile not working when left in background
I open the Power Apps mobile app on either Android or iOS (parameter = 'true') · Switch to another app (Power Apps still...
Read more >
Handling Android App Links
... Address common issues · Improve performace with hardware acceleration ... Access location in the background · Create and monitor geofences · Detect...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found