React Native:链接 API 未发现 Uber 应用 [英] React Native: Linking API not discovering Uber app

查看:44
本文介绍了React Native:链接 API 未发现 Uber 应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,React Native Linking API 的canOpenURL"方法无法检测到我设备上的 Uber 应用程序,即使openURL"方法可以正常打开它.

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 总是 false

推荐答案

您必须将您使用的方案添加到应用程序的 Info.plist LSApplicationQueriesSchemes

You must add the schemes you use to your app's Info.plist LSApplicationQueriesSchemes

来自 canOpenURL:文档:

如果您的应用在 iOS 9.0 或之后链接,您必须声明要传递给此方法的 URL 方案.通过使用 Xcode 项目的 Info.plist 文件中的 LSApplicationQueriesSchemes 数组来执行此操作.对于您希望应用与此方法一起使用的每个 URL 方案,请将其作为字符串添加到此数组中.

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.

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.

这篇关于React Native:链接 API 未发现 Uber 应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆