![](/img/trans.png)
[英]Property 'settings' not found on object of type 'id<CDVCommandDelegate>' in phonegap Urbanairship push notification configuration
[英]PhoneGap (Cordova) CDVCommandDelegate is Nil, How Can I Get Valid Object?
我们正在使用PhoneGap(Cordova)构建我们的应用程序。
但是我有一个单独的Swift项目,我在其中进行所有本机编码,然后将Swift代码复制到PhoneGap构建的.xcodeproj中。
为了使生活更轻松,我将Cordova“安装”到我的Swift项目中,以便我模仿在Cordva生成的应用程序中发生的呼叫。 基本上,我希望能够调用CDVPluginResult并从CDVCommandDelegate发送该结果。
我已经成功安装了Cordova,现在很难工作1件:我的CDVCommandDelegate总是为零。
这是我的代码,用于尝试将图像作为base64字符串发送:
//custom CDVPlugin class that I called CDVPluginDelegate
let _singleton = CDVPluginDelegate()
//handles all CDVPlugin delegation tasks
class CDVPluginDelegate: CDVPlugin
{
class var SINGLETON:CDVPluginDelegate
{
return _singleton
}
}
//getting a picture and returning it
//pass image to phonegap
var imageData = UIImagePNGRepresentation(image)
var base64:String = imageData.base64EncodedStringWithOptions(nil)
var cdvResult:CDVPluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAsString: base64)
println(CDVPluginDelegate.SINGLETON.commandDelegate)//PRINTS nil
CDVPluginDelegate.SINGLETON.commandDelegate.sendPluginResult(cdvResult, callbackId: "imageSent")//crashes because command delegate is nil
如何正确创建/分配此CDVPluginCommand委托?
我不确定为什么,但是当您使用Cordova进行构建时,您只能获得有效的命令委托。 如果您从Cordova进行构建,则命令委托有效,否则(如果您将Cordova作为“插件”安装到现有应用程序中)将为零。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.