Closed anilgunnam closed 2 months ago
A CDVPlugin
has a commandDelegate
property that is a CDVCommandDelegate
. CDVCommandDelegate
is a protocol (interface) that is part of the public API.
CDVCommandDelegateImpl
is the private implementation of that interface, and was never intended to be exposed as public API. In practice, the CDVPlugin
commandDelegate
is a CDVCommandDelegateImpl
instance, but that is an implementation detail. Everything that a plugin should need to do with the command delegate is available on the CDVCommandDelegate
protocol.
In the plugin we use, Main plugin class which extends CDVPlugin has the below, it's using commandDelgate from CDVPlugin: __weak CDVCommandDelegateImpl* delegate = self.commandDelegate;
After this it calls other class in plugin by passing this commanddelegate as parameter. In other class header, import is defined in the as there are methods which has this CDVCommandDelegateImpl parameter:
If i try to use the CDVCommandDelegate interface instead of CDVCommandDelegateImpl in the method declaration, it says invalid type. Any idea on how to fix this?
You'll need to change the other methods to take CDVCommandDelegate*
instead of CDVCommandDelegateImpl*
As, i mentioned earlier, already tried replacing CDVCommandDelegateImpl with CDVCommandDelegate in all header and implementation files like below:
(void) startLogin: (CDVCommandDelegate*) commandDelegate
withCallbackId: (NSString*) callbackId;
Now it is showing an error at startLogin saying : Expected a type for CDVCommandDelegate*
Try id<CDVCommandDelegate>
rather than CDVCommandDelegate*
(since CDVCommandDelegate
is a protocol not a class).
id<CDVCommandDelegate>
means a pointer to a class instance that implements the CDVCommandDelegate
protocol
It's working now. Thank you very much..
We have upgraded from cordova-ios 6.3 to 7. After upgrade cordova iOS build is failing as one of our plugin uses CDVCommandDelegateImpl. Why this is removed from public classes? Is there alternative to the class CDVCommandDelegateImpl which we can use in our plugin?