1import { AndroidConfig, ConfigPlugin, createRunOncePlugin } from 'expo/config-plugins'; 2 3const pkg = require('expo-contacts/package.json'); 4 5const CONTACTS_USAGE = 'Allow $(PRODUCT_NAME) to access your contacts'; 6 7const withContacts: ConfigPlugin<{ contactsPermission?: string } | void> = ( 8 config, 9 { contactsPermission } = {} 10) => { 11 if (!config.ios) config.ios = {}; 12 if (!config.ios.infoPlist) config.ios.infoPlist = {}; 13 config.ios.infoPlist.NSContactsUsageDescription = 14 contactsPermission || config.ios.infoPlist.NSContactsUsageDescription || CONTACTS_USAGE; 15 16 return AndroidConfig.Permissions.withPermissions(config, [ 17 'android.permission.READ_CONTACTS', 18 'android.permission.WRITE_CONTACTS', 19 ]); 20}; 21 22export default createRunOncePlugin(withContacts, pkg.name, pkg.version); 23