【发布时间】:2019-03-07 17:41:12
【问题描述】:
我正在使用 Ionic/Cordova 插件来监视数据集,并希望在本机 api 触发事件时调用我的 typescript 类中的函数。到目前为止我所拥有的是:(打字稿文件)
this.platform.ready().then(() =>{
window.plugins.plugin.startFileWatch("Path", (success) =>{console.log("Succes")}, (error) => {Console.log("ERROR"}))
}
然后在插件中的java脚本中
startFileWatch: function( path, succesCB, errorCB){
exec(succesCB, errorCB, "Class", "startFileWatch", [path]);
}
并在 swift 中(尽管也欢迎使用 android 解决方案):
@objc(startFileWatch:)
func startFileWatch(command:CDVInvokedUrlCommand){
//bit pseudo here
something.addListener{
self?.commandDelage.send(result, callbackID: command.callbackID)
}
}
但这并没有奏效
【问题讨论】:
标签: cordova ionic-framework events callback