Skip to content

Instantly share code, notes, and snippets.

@giautm
Created March 14, 2022 04:17
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giautm/402e1732c89548281d6605ef77289476 to your computer and use it in GitHub Desktop.
Save giautm/402e1732c89548281d6605ef77289476 to your computer and use it in GitHub Desktop.
const { withDangerousMod, withPlugins } = require("@expo/config-plugins");
const {
mergeContents,
} = require("@expo/config-plugins/build/utils/generateCode");
const fs = require("fs");
const path = require("path");
async function readFileAsync(path) {
return fs.promises.readFile(path, "utf8");
}
async function saveFileAsync(path, content) {
return fs.promises.writeFile(path, content, "utf8");
}
const withDisableAdIDSupport = (c) => {
return withDangerousMod(c, [
"ios",
async (config) => {
const file = path.join(config.modRequest.platformProjectRoot, "Podfile");
const contents = await readFileAsync(file);
await saveFileAsync(file, disableAdIDSupport(contents));
return config;
},
]);
};
function disableAdIDSupport(src) {
return mergeContents({
tag: `rn-firebase-disable-ad-id-support`,
src,
newSrc: "$RNFirebaseAnalyticsWithoutAdIdSupport = true",
anchor: /platform :ios/,
offset: 0,
comment: "#",
}).contents;
}
module.exports = (config) => withPlugins(config, [withDisableAdIDSupport]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment