【发布时间】:2018-06-17 20:07:31
【问题描述】:
我希望正确格式化 Info.plist 文件,以便使用 react-native-in-app-utils 进行应用内购买,但我不确定如何格式化数据以及要使用哪种数据插入。
这个帖子提到了在 Info.plist 文件中包含应用程序包 ID 的必要性。
【问题讨论】:
标签: ios reactjs react-native in-app-purchase react-native-in-app-utils
我希望正确格式化 Info.plist 文件,以便使用 react-native-in-app-utils 进行应用内购买,但我不确定如何格式化数据以及要使用哪种数据插入。
这个帖子提到了在 Info.plist 文件中包含应用程序包 ID 的必要性。
【问题讨论】:
标签: ios reactjs react-native in-app-purchase react-native-in-app-utils
如果您使用 expo,它不会将整个 info.plist 暴露给您。
您可以像这样在app.json 中添加一个对象作为ios 对象的子对象:
"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>
查看expos官方文档here
如果您需要对项目进行更多低级别访问,请考虑使用react-native init MyProject 而不是create-react-native-app MyProject。
这将为您提供对所有 ios 和 android 捆绑包的完全访问权限。
或者,如果您已经通过create-react-native-app MyProject 构建了您的应用程序,您可以运行react-native eject 以获取react-native-init MyProject 的构建。
小心,一旦执行此命令,将不会返回。
【讨论】:
infoPlist 条目中放置任意键/值,而无需额外验证。在此处查看文档:docs.expo.io/versions/latest/config/app/#infoplist
expo prebuild 为您的项目生成本机代码,并查看生成的 Info.plist 在托管 EAS 构建中的内容。生成的 Info.plist 在旧的 expo build:ios 项目中可能会有些不同。