Situation: I'm building a cordova plugin to connect an existing iOS library with Ionic. The base mapping of methods is done and working, means I can call the iOS methods via Angular methods and getting success/error callbacks.
Problem: There's a login method which is called, and appropriate delegate methods (e.g. userDidLoginWithSuccess) are called afterwards. Callback from the login method to the cordova plugin is easy, but I need to somehow callback from the delegate method, in order to let the Ionic app know if the user was logged in successfully or not.
Any thoughts on this? Thanks.
PS: I checked this post, which didn't help, although it's a similar question. Phonegap - Send message to Javascript from Objective-c in a plugin delegate
On your .h create a property callbackId that you will use to store the callback identifier of the plugin
@property (nonatomic, strong) NSString* callbackId;
Then, on your plugin method, store the callbackId on the property you created.
self.callbackId = command.callbackId;
and finally, on the delegate send the plugin result using the callbackId
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"string result"];
[self.commandDelegate sendPluginResult:result callbackId:self.callbackId];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With