Skip to content

Instantly share code, notes, and snippets.

@riderx
Last active October 28, 2022 07:45
Show Gist options
  • Save riderx/fc8d0d70e99cc6743a392b0caf315ccf to your computer and use it in GitHub Desktop.
Save riderx/fc8d0d70e99cc6743a392b0caf315ccf to your computer and use it in GitHub Desktop.
fix FMC cordova plugin android 12
// create this file in hooks/before_prepare.js
// add that in config.xml <hook src="hooks/before_prepare.js" type="before_prepare" />
// this file fix the node_module directly, that the only solution i found who work
console.log('Fix activity#com.gae.scaffolder.plugin.FCMPluginActivity')
// if android:name="com.gae.scaffolder.plugin.FCMPluginActivity"> present in platforms/android/app/src/main/AndroidManifest.xml replace by android:name="com.gae.scaffolder.plugin.FCMPluginActivity" android:exported="false">
// open file
const fs = require('fs');
const path = require('path');
// node_modules/cordova-plugin-fcm-with-dependecy-updated/plugin.xml
const manifestPath = path.join(__dirname, '..', 'node_modules', 'cordova-plugin-fcm-with-dependecy-updated', 'plugin.xml');
const manifest = fs.readFileSync(manifestPath, 'utf8');
// replace
// android:name="com.gae.scaffolder.plugin.FCMPluginActivity" android:launchMode="singleTop">
const newManifest = manifest.replace(/android:name="com.gae.scaffolder.plugin.FCMPluginActivity" android:launchMode="singleTop">/g, 'android:name="com.gae.scaffolder.plugin.FCMPluginActivity" android:exported="false" android:launchMode="singleTop">');
// save back
fs.writeFileSync(manifestPath, newManifest, 'utf8');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment