You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native Expo iOS端如何打开默认通讯录应用?

在React Native Expo中打开iOS默认通讯录应用

解决步骤:

  • 先在项目的app.json文件中添加iOS的URL Scheme白名单配置,确保App被允许唤起通讯录应用:
    {
      "expo": {
        "ios": {
          "infoPlist": {
            "LSApplicationQueriesSchemes": ["contacts"]
          }
        }
      }
    }
    
  • 之后使用Linking模块调用正确的URL Scheme打开通讯录:
    import { Linking } from 'react-native';
    
    const openIOSContacts = async () => {
      try {
        const isSupported = await Linking.canOpenURL('contacts://');
        if (isSupported) {
          await Linking.openURL('contacts://');
        } else {
          console.log('无法打开通讯录应用');
        }
      } catch (err) {
        console.error('打开通讯录失败:', err);
      }
    };
    

补充说明:

  • iOS 9及以上版本强制要求在infoPlist中声明LSApplicationQueriesSchemes,否则Linking.canOpenURL()会返回false,也无法唤起对应应用。你之前直接调用Linking.openURL('contacts://')无效,大概率是缺少这个配置。

内容的提问来源于stack exchange,提问作者segev_gr

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 09:24:51