javascript - Callback to Cordova plugin from Objective C delegate - Stack Overflow

Situation: I'm building a cordova plugin to connect an existing iOS library with Ionic. The base m

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 badges
Add a ment  | 

1 Answer 1

Reset to default 9

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 = 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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信