科尔多瓦项目.Firebase插件(自定义插件).我试图弄清楚在添加平台或插件时,指定插件将使用的自定义资源详细信息的正确方法.
例如,Android的API_KEY,APP_ID和google-service.json以及iOS的GoogleServices-Info.plist
我认为在plugin.xml中有API_KEY和APP_ID
<platform name="android">
<preference name="API_KEY"/>
<preference name="APP_ID"/>
<config-file parent="/resources" target="res/values/strings.xml">
<string name="google_app_id">$APP_ID</string>
<string name="google_api_key">$API_KEY</string>
</config-file>
</platform>
Run Code Online (Sandbox Code Playgroud)
所以当添加插件时我会这样做 cordova plugin add myfirebaseplugin --variable APP_ID=blah --variable API_KEY=blah
但我尚未解决的是安装google-service.json或Google-Service.Info.plist的正确方法
我已经试过有--variable IOS_FIREBASE_CONFIG="<path>"和使用<source-file src="$IOS_FIREBASE_CONFIG" target-dir="$PACKAGE_NAME/Resources"/>中plugin.xml,但它似乎源文件不会扩展$ IOS_FIREBASE_CONFIG.
".../plugins/firebase/$IOS_FIREBASE_CONFIG" not found!
Run Code Online (Sandbox Code Playgroud)
插件可以根据我传入的变量处理配置设置吗?或者这是(复制配置文件)config.xml将在平台添加期间处理的东西?
我看了一些firebase插件以及它们如何处理它,似乎它们出来并告诉你手动将配置文件复制到平台文件夹中,这感觉不对.
作为最后的手段,我可能会为平台添加编写一个钩子.
如果您使用的是Cordova CLI 7,则可以resource-file在config.xml中使用tag
您不需要做任何事情,只需记录它,以便用户将文件放在项目的根目录上并将其添加到config.xml中
对于cordova-android 6.xx及更早版本
<platform name="android">
<resource-file src="google-services.json" target="google-services.json" />
</platform>
Run Code Online (Sandbox Code Playgroud)
对于cordova-android 7.xx
<platform name="android">
<resource-file src="google-services.json" target="app/google-services.json" />
</platform>
Run Code Online (Sandbox Code Playgroud)
对于iOS
<platform name="ios">
<resource-file src="GoogleService-Info.plist" />
</platform>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3344 次 |
| 最近记录: |