首页 > 解决方案 > 如何将 Fabric API 密钥和秘密传递给 cordova-plugin-firebase?

问题描述

我已经使用了cordova-fabric-plugin多年。作为 Fabric 项目的链接,您可以向该插件传递两个参数:一个 API 密钥和一个 API 秘密,如下所示:

cordova plugin add cordova-fabric-plugin --variable FABRIC_API_KEY=XXX --variable FABRIC_API_SECRET=xxx

这会导致config.xml像这样的更新文件:

<plugin name="cordova-fabric-plugin" spec="^1.1.10">
      <variable name="FABRIC_API_KEY" value="XXX" />
      <variable name="FABRIC_API_SECRET" value="xxx" />
</plugin>

现在,我需要通过cordova-plugin-firebase包含自己的 Fabric 框架的 将 Firebase 安装到我的项目中。但我找不到动态传递这些相同参数的方法。我一直在对两个插件代码进行一些研究:

cordova-fabric-plugin来自的样本ios-helper.js file

    // Read and parse the XCode project (.pxbproj) from disk.
            // File format information: http://www.monobjc.net/xcode-project-file-format.html
            var xcodeProject = xcode.project(xcodeProjectPath);
            xcodeProject.parseSync();

            // Build the body of the script to be executed during the build phase.
            var script = '"' + '${SRCROOT}' + "/\\\"" + utilities.getAppName(context) + "\\\"/Plugins/cordova-fabric-plugin/Fabric.framework/run " 
+ pluginConfig.apiKey + " " + pluginConfig.apiSecret + '"';

现在从cordova-plugin-firebase'shelper.js文件:

// Read and parse the XCode project (.pxbproj) from disk.
    // File format information: http://www.monobjc.net/xcode-project-file-format.html
    var xcodeProject = xcode.project(xcodeProjectPath);
    xcodeProject.parseSync();

    // Build the body of the script to be executed during the build phase.
    var script = '"' + '\\"${SRCROOT}\\"' + "/\\\"" + utilities.getAppName(context) + "\\\"/Plugins/" + utilities.getPluginId() + "/Fabric.framework/run" + '"';

==>参数不用了!尝试将新版本推送到 Fabric 时出现以下错误:

Fabric API 密钥无效。您的 Fabric 运行脚本构建阶段应包含您的 API 密钥:./Fabric.framework/run INSERT_YOUR_API_KEY INSERT_YOUR_BUILD_SECRET

我可以手动向 XCode 键入密钥和秘密,但我需要一个动态的解决方法来工业化这个过程。

有解决方案的人吗?

提前致谢

标签: javascriptfirebasecordovacordova-plugins

解决方案


推荐阅读