Info.plist file for react native ios app using expo SDK
Asked Answered
G

1

25

I'm looking to properly format the Info.plist file in order to make in app purchase work with react-native-in-app-utils but I'm not sure how to format the data and what kind of data to insert.

This thread mentions the necessity to include the app bundle id inside the Info.plist file.

iOS in app purchase - no products received

Genisia answered 8/1, 2018 at 19:53 Comment(0)
S
76

If you are using expo, it will not expose the entire info.plist to you.

Expo Workaround

You can add an object as a child of ios object in the app.json like so:

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

Which will write to the native level but this is limited. Here is a list of all the keys you can access with while using 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>

View expos official docs here

React-native Init

If you need more low level access to your project, consider using react-native init MyProject instead of create-react-native-app MyProject.

This will provide you with full access to all ios and android bundles.

React-native eject

Or if you already built your app via create-react-native-app MyProject you can run react-native eject to get the build of react-native-init MyProject.

Be cautious, there is no returning once this command is ran.

Sensible answered 11/1, 2018 at 4:22 Comment(4)
I'm not sure if this changed since you posted this answer, but expo's docs specify that you can put any arbitrary key / values in the infoPlist entry with no additional validation now. See the docs here: docs.expo.io/versions/latest/config/app/#infoplistCantwell
You can run expo prebuild to generate the native code for your project and see what the resulting Info.plist would be in a managed EAS build. The resulting Info.plist could be a bit different in a legacy expo build:ios project.Suspensive
Do you know the syntax for doing this to allow NSAllowsArbitraryLoads to be true? I need to enable http calls for development but I can't get the setting detected.Zoomorphism
This may have changed since this was originally created, but according to Expo's current info, "infoPlist" is a "Dictionary of arbitrary configuration to add to your standalone app's native Info.plist. Applied prior to all other Expo-specific configuration. No other validation is performed, so use this at your own risk of rejection from the App Store.". So should support any arbitrary Info.plist values.Basinger

© 2022 - 2024 — McMap. All rights reserved.