Linking.getInitialURL() url value is null
See original GitHub issueIs this a bug report?
Yes
Have you read the Contributing Guidelines?
Yes
Environment
react-native -v
: 2.0.1node -v
: 8.4.0npm -v
: 4.6.1
Then, specify:
- Target Platform: Android
- Development Operating System: MacOs Sierra
- Build tools: Application created using create-react-native-app and then detached with support of Expo SDK
Steps to Reproduce
(Write your steps here:)
- Create application using create-react-native-app
- Detach application with: npm run eject (keep support of Expo SDK)
- Update AndroidManifest.xml with respective deep links filters inside MainActivity
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https"
android:host="www.mydomain.com"
android:pathPrefix="/" />
<data android:scheme="https"
android:host="www.mydomain.com" />
</intent-filter>
- Update activity declaration with
android:launchMode="singleTask"
- Update application component to load url on componentDidMount:
componentDidMount() {
Linking.getInitialURL().then((url) => {
console.log('Inside of the function is: ' + url);
this._handleOpenURL(url);
}).catch(err => console.error('An error occurred', err));
}
- Find url is always null
Expected Behavior
url variable populated with respective Url application was loaded with
Actual Behavior
Url is null
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:10 (1 by maintainers)
Top Results From Across the Web
iOS Linking getInitialURL() always null · Issue #24429 - GitHub
3 it's working via getInitialUrl() and listener. I tried on React Native 0.59.4 not working. To Reproduce. 1. Add URL type to info.plist....
Read more >Why is Linking.getInitialURL always returning null?
The response was always null if I was debugging remotely. If the remote debugger was off, then I would get the correct url....
Read more >Native App Deep Link not working | Mendix Forum
getInitialURL() in RegisterDeepLink is returning null value because of this deep link url registration is failing. I am running the App locally ...
Read more >Linking - Expo Documentation
Returns the initial URL or null . ... Linking.getInitialURL(). Get the URL that was used to launch the app if it was ......
Read more >Linking · React Native
componentDidMount() { Linking.getInitialURL().then((url) => { if (url) { console.log('Initial url is: ' + url); } }).catch(err => console.error('An error ...
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
Same issue
Solved it! I’ll explain what the problem for us was, if anyone is facing the same issue as we did.
We had a custom activity called “SplashActivity” where we had added the
In our
SplashActivity.java
we started the MainActivity like this:For RN to pick up the url from
getInitialURL()
, we need to pass the data and action to our MainActivity. So basically we just passed the required information to our MainActivity (inSplashActivity.java
):(don’t forget to
import android.content.Intent;
andimport android.net.Uri;
)This solved it for us.