fixQRScanner.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. const fs = require("fs");
  2. const path = require("path");
  3. const https = require("https");
  4. module.exports = function (context) {
  5. if (
  6. context.opts.plugin &&
  7. context.opts.plugin.id === "cordova-plugin-qrscanner"
  8. ) {
  9. const projectRoot = context.opts.projectRoot;
  10. const cordovaCommon = context.requireCordovaModule("cordova-common");
  11. const { ConfigParser } = cordovaCommon;
  12. const appConfig = new ConfigParser(
  13. path.resolve(projectRoot, "config.xml")
  14. );
  15. let projectName = appConfig.name();
  16. const file = path.resolve(
  17. projectRoot,
  18. "platforms",
  19. "ios",
  20. projectName,
  21. "Plugins",
  22. "cordova-plugin-qrscanner",
  23. "QRScanner.swift"
  24. );
  25. if (fs.existsSync(file)) {
  26. fs.writeFileSync(
  27. file,
  28. fs
  29. .readFileSync(file)
  30. .toString()
  31. .replaceAll(
  32. "UIApplication.openSettingsURLString",
  33. "UIApplicationOpenSettingsURLString"
  34. )
  35. );
  36. }
  37. }
  38. };