Goal C send data to phonegap and call javascript function

I am developing an ios application using phonegap. Because he needs to implement face recognition, so I also use the objective-c native language here.

In the main story pane, I have two view controllers. One of them is called "FaceRec", it is completely created using objective-c. The face recognition function is implemented here. The other is the phonegap main view controller. They connect using the Tab Bar Controller.

The problem is that the user enters the FaceRec page from the control panel of the panel and receives a response from the server. If the answer is correct, I do not know how to send this response from FaceRec to the phonegap main screen manager. Since they are in a different view controller, and I also don't know how to call the javascript function from objective-c.

I know, using the plugin, I can call the objective-c method from javascript and also get a response, but I want to send the data from objective-c to the telephone disassembly via another view controller and call the javascript function.

Any ideas? Thanks in advance!

Here is the code in index.html:

<script type="text/javascript"> function login() { $(function() { $.mobile.navigate( "#main", { transition : "slide", info: "info about the #bar hash" }); }); } </script> <div id="loginPage" data-role="page" data-theme="b">; <div id="main" data-role="page" data-theme="b"> 
+1
source share
1 answer

To call a Javascript function from Obj-C using something like:

 [self writeJavascript:@"YourJSFunction();"]; 

You can also pass everything as a string in JS :

 NSString *js = @"YourJSFunction('"; js = [js stringByAppendingString:yourData]; js = [js stringByAppendingString:@"');"]; [self writeJavascript:js]; 

Where yourData should be a string. You can JSON Serialize basically almost any arrays or dictionaries to pass it into your javascript function.

-1
source

All Articles