Phonegap Cordova call javascript functions from Objective-C -


i facing objective-c lackiness of knowledge in phonegap app.

i have library need implement in objective-c. library has callbacks receive in delegate class ( called cccontroller ) :

[mylib sharedinstance].delegate = self; 

this class instanciated in appdelegate.m :

cccontroller *myclass = [cccontroller alloc]; [myclass init]; 

then, when lib sends events, functions in cccontroller called. need, @ point, call javascript functions parameter.

how can implement ?

i have tried calling function in appdelegate.m contains :

nsstring* jsstring = [nsstring stringwithformat:@"myjsfunction(\"%@\");", stringparameter]; [self.viewcontroller.webview stringbyevaluatingjavascriptfromstring:jsstring]; 

but without success, nothing called in js...

how can implement ? :)

you have create plugin , put native code there instead using in appdelegate.m.

from plugin class can this:

nsstring* jsstring = [nsstring stringwithformat:@"myjsfunction(\"%@\");", stringparameter]; [self.webview stringbyevaluatingjavascriptfromstring:jsstring]; 

plugin development guide


Comments