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
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
Share Improve this question edited May 23, 2017 at 11:54 CommunityBot 11 silver badge asked Sep 22, 2015 at 14:02 DaniDani 1237 bronze badges1 Answer
Reset to default 9On 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 = mand.callbackId;
and finally, on the delegate send the plugin result using the callbackId
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"string result"];
[self.mandDelegate sendPluginResult:result callbackId:self.callbackId];
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745048014a4608213.html
评论列表(0条)