Info.plist 文件,用于使用 expo SDK 响应本机 ios 应用程序

IT技术 ios reactjs react-native in-app-purchase react-native-in-app-utils
2021-03-27 19:43:38

我希望正确格式化 Info.plist 文件,以便使用 react-native-in-app-utils 进行应用内购买,但我不确定如何格式化数据以及要插入的数据类型。

该线程提到在 Info.plist 文件中包含应用程序包 ID 的必要性。

iOS 应用内购买 - 未收到任何产品

1个回答

如果您使用 expo,它不会info.plist向您公开整个内容。

世博会解决方法

您可以将对象添加为对象的子ios对象,如下app.json所示:

"infoPlist": {
  "NSCameraUsageDescription": "This app uses the camera to scan barcodes on event tickets."
},

这将写入本机级别,但这是有限的。这是您在使用 expo 时可以访问的所有密钥的列表

<key>NSCameraUsageDescription</key>
<string>Allow Expo experiences to use your camera</string>
<key>NSContactsUsageDescription</key>
<string>Allow Expo experiences to access your contacts</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Allow Expo experiences to use your location</string>
<key>NSMicrophoneUsageDescription</key>
<string>Allow Expo experiences to access your microphone</string>
<key>NSMotionUsageDescription</key>
<string>Allow Expo experiences to access your device's accelerometer</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Give Expo experiences permission to save photos</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Give Expo experiences permission to access your photos</string>

在此处查看博览会官方文档

react-native初始化

如果你需要你的项目更多的低级别的访问权限,可以考虑使用react-native init MyProject替代create-react-native-app MyProject

这将为您提供对所有 ios 和 android 包的完全访问权限。

react-native弹出

或者,如果您已经通过构建应用程序,则create-react-native-app MyProject可以运行react-native eject以获取react-native-init MyProject.

小心,一旦运行此命令就不会返回。

您可以运行expo prebuild为您的项目生成本机代码,并查看Info.plist托管 EAS 构建中的结果。生成的 Info.plist 在遗留expo build:ios项目中可能会有所不同
2021-05-30 19:43:38
我不确定自从您发布此答案后这是否发生了变化,但 expo 的文档指定您可以在infoPlist条目中放置任意键/值,现在无需额外验证。请参阅此处的文档:docs.expo.io/versions/latest/config/app/#infoplist
2021-06-05 19:43:38