How to add codes in your Info.plist file using expo
Inside your app.plugin.js file, add the following code.
const { withInfoPlist } = require('expo/config-plugins');
module.exports = function myCustomExpoFunctionName(config) {
config = withInfoPlist(config, (config) => {
/*
Type 1
Code to add in Info.plist file (String)
*/
config.modResults['YourCustomMessageKey'] = 'Your custom message';
/*
Type 1
Result in Info.plist file as below
<key>YourCustomMessageKey</key>
<string>Your custom message</string>
*/
/*
Type 2
Code to add in Info.plist file (Dictionary)
*/
config.modResults.MyCustomDictionary = {
MY_FIRST_KEY: 'My first value',
MY_SECOND_KEY: 'My second value'
};
/*
Type 2
Result in Info.plist file as below
<key>MyCustomDictionary</key>
<dict>
<key>MY_FIRST_KEY</key>
<string>My first value</string>
<key>MY_SECOND_KEY</key>
<string>My second value</string>
</dict>
*/
/*
Type 3
Code to add in Info.plist file (Array)
*/
config.modResults.MyCustomArray = ['My first value', 'My second value'];
/*
Type 3
Result in Info.plist file as below
<key>MyCustomArray</key>
<array>
<string>My first value</string>
<string>My second value</string>
</array>
*/
return config;
});
return config;
};