Linking.getInitialURL in standalone in iOS fails to pass additional data in the URL
See original GitHub issueWhen using Linking.getInitialURL
to retrieve the URL (in a standalone iOS app with a custom scheme) when the app is first loaded (not when foregrounded), only the prefix is returned.
For example, attempting to open the app using custom scheme test
with test://something
, the URL retrieved with Linking.getInitialURL
will return only the prefix test://
.
Environment
Environment: OS: macOS High Sierra 10.13.4 Node: 8.9.0 Yarn: 0.22.0 npm: 5.8.0 Watchman: 4.9.0 Xcode: Xcode 9.3 Build version 9E145 Android Studio: 3.1 AI-173.4670197
Packages: (wanted => installed) expo: ^26.0.0 => 26.0.0 react: 16.3.0-alpha.1 => 16.3.0-alpha.1 react-native: https://github.com/expo/react-native/archive/sdk-26.0.0.tar.gz => 0.54.2
Diagnostics report: https://exp-xde-diagnostics.s3.amazonaws.com/gradealabs-903bc80d-7584-4adb-b9cc-a451803284e8.tar.gz
Steps to Reproduce
In order to make this as easy as possible, I’ve written a bash script to create a test
project, build it for simulator, download it, and install it in the iOS simulator automatically.
- Create this script and run it in a scratch folder of your choosing. A
test
project will be created within:
#!/bin/bash
set -e
exp init test --template blank
cd test
cat > App.js <<- EOM
import React from 'react';
import { StyleSheet, Text, View, Linking } from 'react-native';
export default class App extends React.Component {
constructor(props) {
super(props)
this.state = { url: '' }
}
componentDidMount() {
Linking.getInitialURL().then(url => this.setState({ url }))
}
render() {
return (
<View style={styles.container}>
<Text>URL: {this.state.url}</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
EOM
cat > app.json <<- EOM
{
"expo": {
"name": "test",
"description": "This project is really great.",
"slug": "test",
"scheme": "test",
"privacy": "public",
"sdkVersion": "26.0.0",
"platforms": ["ios", "android"],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.test.test"
}
}
}
EOM
rm -f /tmp/ios-app.tar.gz
exp build:ios --type simulator | grep -Eo "Successfully built standalone app: (.+)" | cut -d: -f2,3 | xargs curl -o /tmp/ios-app.tar.gz
rm -rf /tmp/test.app
tar -xvzf /tmp/ios-app.tar.gz -C /tmp
open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app
while : ; do
count=$(xcrun simctl list | grep Booted | wc -l | sed -e 's/ //g')
[ $count -lt 1 ] || break
sleep 1
done
xcrun simctl install booted /tmp/test.app
-
Make sure the app is not currently running in the simulator, as we are not concerned with the behavior when the app is foregrounded
-
Launch the app in the simulator via Safari, such as
test://thisshouldwork
-
Look for the URL being displayed in the app
Expected Behavior
The app should display: URL: test://thisshouldwork
Actual Behavior
The app displays: URL: test://
Reproducible Demo
See above installation script and demo video.
EDIT: changed wget
to curl
in the script
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (5 by maintainers)
Anyone still encountering this issue but when opening an App from a notification deep link?
Confirming that this is indeed resolved with SDK 27. 👍