ios - react native : Linking API not discovering Uber app

标签 ios react-native

出于某种原因,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’s Info.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/

相关文章:

ios - 使用 ccrypto RSA 加密 2500 字节数据

objective-c - 如何将 subview 添加到 View

reactjs - 解决 Expo 和 React Native 的依赖冲突

react-native - iOS 上的 AWSS3TransferUtilityErrorDomain 代码=2

javascript - 使用 React Native 异步返回一个值

ios - 书籍结构(目录)和内容的数据库设计

ios - Xcode 内存泄漏问题

iphone - 向网站发送数据并获取搜索结果 iOS

javascript - 没有带有 fetch() 的 JSON 对象

ios - 新的 React Native 项目失败 : Entry, ":CFBundleIdentifier",不存在