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

iOS集成@ajith-ab/react-native-receive-sharing-intent报文件类型无效错误求助

解决iOS集成@ajith-ab/react-native-receive-sharing-intent时的"file type is Invalid"错误

1. 检查Info.plist的文件类型配置

确保iOS项目的Info.plist中正确声明了要接收的文件类型,添加对应UTI(Uniform Type Identifiers):

  • 打开ios/[你的项目名]/Info.plist
  • 添加CFBundleDocumentTypes数组,示例配置:
<key>CFBundleDocumentTypes</key>
<array>
  <dict>
    <key>CFBundleTypeName</key>
    <string>Image</string>
    <key>LSHandlerRank</key>
    <string>Alternate</string>
    <key>LSItemContentTypes</key>
    <array>
      <string>public.image</string>
      <string>public.jpeg</string>
      <string>public.png</string>
    </array>
  </dict>
  <dict>
    <key>CFBundleTypeName</key>
    <string>Document</string>
    <key>LSHandlerRank</key>
    <string>Alternate</string>
    <key>LSItemContentTypes</key>
    <array>
      <string>public.text</string>
      <string>public.pdf</string>
    </array>
  </dict>
</array>

同时确认开启文件共享:

<key>UIFileSharingEnabled</key>
<true/>

2. 验证iOS原生代码的类型判断逻辑

检查库的iOS原生文件RNReceiveSharingIntent.m中handleShare方法的类型校验逻辑,确认是否遗漏了你要接收的文件UTI,若有自定义类型需手动添加到允许列表。

3. 清理缓存并重新构建

  • 执行命令清理iOS依赖:pod deintegrate && pod install
  • 删除Xcode的Derived Data:Xcode → Preferences → Locations → Derived Data,打开文件夹后删除对应项目缓存
  • 重启模拟器/真机,重新运行项目

4. 确认共享文件的实际类型

测试时共享的文件需在你配置的支持类型范围内,比如若只声明了jpeg/png,共享webp格式图片就会触发错误,可通过iOS文件应用查看文件详细类型。

5. 调整库版本

若为新版本引入的问题,尝试升级到最新版或回退到之前集成成功的版本:

npm install @ajith-ab/react-native-receive-sharing-intent@[你之前成功的版本号]

之后重新执行pod install并构建项目

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.05 17:02:33