08f6caa645
* feat: add expo plugins * add export * fix import * fix bugs * build `lib` to `CommonJS` * restore `build.gradle` * remove plugin tmp * add expo plugin for ios caching * add docs for expo plugin * fix expo plugin export * fix docs
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import {
|
|
withGradleProperties,
|
|
type ConfigPlugin,
|
|
withDangerousMod,
|
|
} from '@expo/config-plugins';
|
|
import {writeToPodfile} from './writeToPodfile';
|
|
|
|
/**
|
|
* Sets whether to enable the IMA SDK to use ADS with `react-native-video`.
|
|
*/
|
|
export const withAds: ConfigPlugin<boolean> = (c, enableADSExtension) => {
|
|
const android_key = 'RNVideo_useExoplayerIMA';
|
|
const ios_key = 'RNVideoUseGoogleIMA';
|
|
|
|
// -------------------- ANDROID --------------------
|
|
const configWithAndroid = withGradleProperties(c, (config) => {
|
|
config.modResults = config.modResults.filter((item) => {
|
|
if (item.type === 'property' && item.key === android_key) {
|
|
return false;
|
|
}
|
|
return true;
|
|
});
|
|
|
|
config.modResults.push({
|
|
type: 'property',
|
|
key: android_key,
|
|
value: enableADSExtension.toString(),
|
|
});
|
|
|
|
return config;
|
|
});
|
|
|
|
// -------------------- IOS --------------------
|
|
const complectedConfig = withDangerousMod(configWithAndroid, [
|
|
'ios',
|
|
(config) => {
|
|
writeToPodfile(
|
|
config.modRequest.projectRoot,
|
|
ios_key,
|
|
enableADSExtension.toString(),
|
|
);
|
|
return config;
|
|
},
|
|
]);
|
|
|
|
return complectedConfig;
|
|
};
|