react-native-cloud-storage
Version:
☁️ Save to & read from iCloud and Google Drive using React Native
33 lines (32 loc) • 1.79 kB
JavaScript
;
import { withEntitlementsPlist, withInfoPlist, withPlugins } from '@expo/config-plugins';
const getICloudContainerIdentifier = (config, options) => {
if (options?.iCloudContainerIdentifier) return options.iCloudContainerIdentifier;
if (!config?.ios?.bundleIdentifier) throw new Error('Missing iOS bundle identifier');
return `iCloud.${config.ios.bundleIdentifier}`;
};
const withRNCloudStorageInfoPlist = (config, options) => withInfoPlist(config, async newConfig => {
const infoPlist = newConfig.modResults;
infoPlist.NSUbiquitousContainers = {
[getICloudContainerIdentifier(config, options)]: {
NSUbiquitousContainerIsDocumentScopePublic: true,
NSUbiquitousContainerSupportedFolderLevels: 'Any',
NSUbiquitousContainerName: config.slug
}
};
return newConfig;
});
const withRNCloudStorageEntitlementsPlist = (config, options) => withEntitlementsPlist(config, async newConfig => {
if (!config.ios?.bundleIdentifier) {
throw new Error('Missing iOS bundle identifier');
}
const entitlementsPlist = newConfig.modResults;
entitlementsPlist['com.apple.developer.icloud-container-identifiers'] = [getICloudContainerIdentifier(config, options)];
entitlementsPlist['com.apple.developer.icloud-services'] = ['CloudDocuments'];
entitlementsPlist['com.apple.developer.icloud-container-environment'] = options?.iCloudContainerEnvironment ?? 'Production';
entitlementsPlist['com.apple.developer.ubiquity-container-identifiers'] = [getICloudContainerIdentifier(config, options)];
return newConfig;
});
const withRNCloudStorageIos = (config, options) => withPlugins(config, [[withRNCloudStorageInfoPlist, options], [withRNCloudStorageEntitlementsPlist, options]]);
export default withRNCloudStorageIos;
//# sourceMappingURL=ios.js.map