Jscontext *context = [Self.webview valueforkeypath:@ "DocumentView.webView.mainFrame.javaScriptContext"]; Jstextobject * Jsiosobject = [Jstextobject new]; context[@ "Jstextobject"] = Jsiosobject; NSString *[email protected] "jstextobject.calliosfunction ()"; Jsvalue *value1 = [Context evaluatescript:jsstr1]; Ddloginfo (@ "The value 1 is%@", value1); NSString *[email protected] "jstextobject.calliosfunctionparamter (' hello ')"; Jsvalue *value2 = [Context evaluatescript:jsstr2]; Ddloginfo (@ "The value 1 is%@", value2); context[@ "test1"] = ^ () {Nsarray *args = [Jscontext currentarguments]; for (id obj in args) {NSLog (@ "Test1%@", obj); } }; context[@ "Share"] = ^ () {NSLog (@ "+++++++begin log+++++++"); Nsarray *args = [Jscontext currentarguments]; Dispatch_async (Dispatch_get_main_queue (), ^{//uialertview *alertview = [[Uialertview alloc] Initwith title:@ "Way Two" message: @ "This is the OC native Pop-up window" Delegate:self cancelbuttontitle:@ "received" otherbuttontitles:nil];//[Alertview show];//}); NSString *title = @ ""; For (Jsvalue *jsval in args) {if ([title isequaltostring:@ "]) {title = jsval.tostring; } NSLog (@ "%@", jsval.tostring); } dispatch_async (Dispatch_get_main_queue (), ^{uialertview *alertview = [[Uialertview alloc] Ini twithtitle:@ "Way II" Message:title delegate:self cancelbuttontitle:@ "received" otherbuttontitles:nil]; [Alertview show]; }); NSLog (@ "-------End Log-------"); };
H5 interacting with apps