出于某种原因,React Native Linking API 的“canOpenURL”方法无法检测到我设备上的 Uber 应用程序,即使“openURL”方法可以正常打开它。
下面有什么我遗漏的吗?
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 总是false
最佳答案
您必须将您使用的方案添加到应用程序的 Info.plist LSApplicationQueriesSchemes
来自canOpenURL :文档:
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.
如果您的(iOS 9.0 或更高版本)应用程序使用您未声明的方案调用此方法,则无论设备上是否安装了适合该方案的应用程序,该方法都会返回 NO。
关于ios - react native : Linking API not discovering Uber app,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36742013/