Deep linking in Android not working if the app is in the background
See original GitHub issueIs 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
- Add
Linking.addEventListener
tocomponentDidMount
, withalert
callback, just to check if it works; - Put the app in background;
- 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:
- Created 6 years ago
- Reactions:1
- Comments:5
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have the same issue in iOS @GopiKrishna10 - How did you solve this for iOS ?
Did anyone found the solution for this?