Skip to content

A bridge used for Objective-C and JavaScript, which realizes the same mechanism as in Android. Some code referenced from WebViewJavaScriptBridge.

License

Notifications You must be signed in to change notification settings

ccnyou/WebViewJsBridge

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebViewJsBridge

A bridge used for Objective-C and JavaScript, which implements the same mechanism as in Android.

Usage

  • Inject Native OC Object:
    JsObject* jsObject = [[JsObject alloc] init];
    [_webview yoyo_addJavascriptInterface:jsObject forName:@"JsNative"];
    [_webview loadHTMLString:appHtml baseURL:nil];
  • Js callback
	// js: JsNative.testCallback1("arg1", "call_back_name");
	[webview yoyo_excuteJSWithObj:@"window" function:@"call_back_name" args:@[result]];

	// js: JsNative.testCallback1("arg1", function(arg) {});
	[webview yoyo_executeCallback:@[result]];

About

A bridge used for Objective-C and JavaScript, which realizes the same mechanism as in Android. Some code referenced from WebViewJavaScriptBridge.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Objective-C 86.0%
  • HTML 7.4%
  • JavaScript 6.6%