我正试图使用定制的cordova插件从离子型1到ios快速本地版进行通信,为此,我开发了一个https://moduscreate.com/blog/writing-a-cordova-plugin-in-swift-for-ios/插件,这个文档就是这样。但我无法沟通。我得到了:
-CDVCommandQueue executePending pluginJSON = ["LiveConnectCordova486334569“、"LiveConnectCordova”、"echo“、"jai"]
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
<plugin id="com-fibase-ionic-ios-multivideo" version="0.0.1"
xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"> .
<name>LiveConnectCordova</name>
<platform name="ios">
<config-file parent="/*" target="config.xml">
<feature name="LiveConnectCordova">
<param name="ios-package" value="LiveConnectCordova" />
</feature>
</config-file>
<js-module name="LiveConnectCordova" src="www/LiveConnectCordova.js">
<clobbers target="LiveConnectCordova" />
</js-module>
<source-file src="src/ios/LiveConnectCordova.swift" />
<dependency id="cordova-plugin-add-swift-support" version="1.7.2"/>
</platform>
plugin.js
var exec = require('cordova/exec');
exports.coolMethod = function (arg0, success, error) {
exec(success, error, 'LiveConnectCordova', 'echo', [arg0]);
};我的敏捷课
@objc(LiveConnectCordova) class LiveConnectCordova : CDVPlugin {
func echo(command: CDVInvokedUrlCommand) {
var pluginResult = CDVPluginResult(
status: CDVCommandStatus_ERROR
)
let msg = command.arguments[0] as? String ?? ""
if msg.characters.count > 0 {
pluginResult = CDVPluginResult(
status: CDVCommandStatus_OK,
messageAs: msg
)
}
self.commandDelegate!.send(
pluginResult,
callbackId: command.callbackId
)
}
}发布于 2018-12-06 07:18:30
您需要更新您的LiveConnectCordova.js文件代码,如下所述。
var exec = require('cordova/exec');
exports.echo = function (arg0, success, error) {
exec(success, error, 'LiveConnectCordova', 'echo', [arg0]);
};当您从您的Ionic代码中调用echo方法时。
也可以像下面这样调用插件方法。
window["LiveConnectCordova"].echo(
param,
function(res) {
console.log("Response :", res);
},
function(err) {
console.log("Error :", err);
}
);在你的应用程序中尝试上面的调用。
希望这会有帮助!
https://stackoverflow.com/questions/53606051
复制相似问题