Reputation: 502
For some reason the React Native Linking API's "canOpenURL" method can't detect the Uber app on my device, even though the "openURL" method opens it fine.
Is there something I'm missing below?
constructor(props) {
super(props);
this.state = {
uberURL: 'uber://?client_id=eJCfG86Rz&action=setPickup',
isUberInstalled: false
};
}
componentWillMount() {
Linking.canOpenURL(this.state.uberURL).then(isUberInstalled => {
this.setState({ isUberInstalled: isUberInstalled });
});
}
this.state.isUberInstalled is always false
Upvotes: 2
Views: 2693
Reputation: 2966
You must add the schemes you use to your app's Info.plist LSApplicationQueriesSchemes
From the canOpenURL: documentation:
If your app is linked on or after iOS 9.0, you must declare the URL schemes you want to pass to this method. Do this by using the
LSApplicationQueriesSchemes
array in your Xcode project’sInfo.plist
file. For each URL scheme you want your app to use with this method, add it as a string in this array.
If your (iOS 9.0 or later) app calls this method using a scheme you have not declared, the method returns NO, whether or not an appropriate app for the scheme is installed on the device.
Upvotes: 6