【问题标题】:React Native: Linking API not discovering Uber appReact Native:链接 API 未发现 Uber 应用程序
【发布时间】:2016-04-20 11:11:33
【问题描述】:

由于某种原因,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

【问题讨论】:

    标签: ios react-native


    【解决方案1】:

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

    来自canOpenURL:文档:

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

    如果您的(iOS 9.0 或更高版本)应用使用您未声明的方案调用此方法,则该方法返回 NO,无论设备上是否安装了适用于该方案的应用。

    【讨论】:

    • 传奇!谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-07
    • 1970-01-01
    • 2019-03-15
    • 1970-01-01
    • 2022-12-20
    • 1970-01-01
    相关资源
    最近更新 更多