react-native - opneUrl react native 链接调用,mailto

标签 react-native openurl

我正在尝试打开一个网址(“tel:061245124”或“mailto:test@test.com”),它说我可以处理网址,也尝试过不使用电话:或邮件,但它崩溃了红屏。 像“http://test.com”这样的网址有效。 我做错了什么?

    handlePress(url) {
    console.tron.log('Trying to access url')
    console.tron.log(url)
    Linking.canOpenURL(url).then(supported => {
      if (!supported) {
        console.tron.log('Can\'t handle url: ' + url)
      } else {
        return Linking.openURL(url)

      }
    }).catch(err => console.error('An error occurred', err))
  }

最佳答案

代码运行完美,问题出在 iOS 模拟器上,需要在设备上进行测试。

关于react-native - opneUrl react native 链接调用,mailto,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44769710/

相关文章:

javascript - 使用 react 导航条件渲染屏幕

swift3 - 如何在 Swift 3 中打开 WIFI 设置

iphone - 使用 objective-c 程序在 safari 中打开和关闭 url

ios - 我如何在 iOS Swift 3 中以编程方式完成移动数据设置

cocoa-touch - 如何调用电话、发送短信或在 map 上查找地址?

javascript - Expo - React Native - Metro 配置文件

react-native - 如何在React Native应用程序中使用Redux RTK访问状态

android - 在 React Native 中使用 Expo 会最差吗?

android - 网络请求失败在 https 图像上传 Android 上做出 native react

ios - 尝试使用 tel ://scheme on iOS 10. 3 调用电话号码时提示