【问题标题】:Info.plist file for react native ios app using expo SDK使用 expo SDK 反应原生 ios 应用程序的 Info.plist 文件
【发布时间】:2018-06-17 20:07:31
【问题描述】:

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

这个帖子提到了在 Info.plist 文件中包含应用程序包 ID 的必要性。

iOS in app purchase - no products received

【问题讨论】:

    标签: ios reactjs react-native in-app-purchase react-native-in-app-utils


    【解决方案1】:

    如果您使用 expo,它不会将整个 info.plist 暴露给您。

    Expo 解决方法

    您可以像这样在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 项目中可能会有些不同。
    猜你喜欢
    • 1970-01-01
    • 2016-08-23
    • 2020-03-10
    • 1970-01-01
    • 1970-01-01
    • 2019-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多