我想正确地格式化Info.plist文件,以便在react-native-in-app-utils中使用应用内购买功能,但我不确定如何格式化数据以及插入什么类型的数据。
这个帖子提到在Info.plist文件中包括应用程序包标识的必要性。
我想正确地格式化Info.plist文件,以便在react-native-in-app-utils中使用应用内购买功能,但我不确定如何格式化数据以及插入什么类型的数据。
这个帖子提到在Info.plist文件中包括应用程序包标识的必要性。
如果你在使用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>
查看 Expo 官方文档这里
如果您需要更低级别的访问权限,请考虑使用react-native init MyProject
而不是create-react-native-app MyProject
。
这将为您提供对所有 iOS 和 Android 包的完全访问权限。
或者,如果您已经通过create-react-native-app MyProject
构建了您的应用程序,则可以运行react-native eject
来获取react-native-init MyProject
的构建版本。
请注意,运行此命令后无法返回。
expo prebuild
来为您的项目生成本机代码,并查看在托管的 EAS 构建中生成的Info.plist
。 在传统的expo build:ios
项目中,生成的 Info.plist 可能会略有不同。 - Evan BaconNSAllowsArbitraryLoads
为 true 吗?我需要在开发中启用 HTTP 调用,但是我无法使设置被检测到。 - Eric Hasegawa