All Projects → carlSQ → FMWebViewJavascriptBridge

carlSQ / FMWebViewJavascriptBridge

Licence: MIT license
FMWebViewJavascriptBridge inspired by WebViewJavascripBridge and react native

Programming Languages

objective c
16641 projects - #2 most used programming language
javascript
184084 projects - #8 most used programming language
HTML
75241 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to FMWebViewJavascriptBridge

WebViewJavascriptBridge
This is a communication between Android applications and Web Javascript to establish a bridge between the call support each other
Stars: ✭ 16 (-44.83%)
Mutual labels:  bridge, webviewjavascriptbridge
Dsbridge Ios
🌏 A modern cross-platform JavaScript bridge, through which you can invoke each other's functions synchronously or asynchronously between JavaScript and native.
Stars: ✭ 1,673 (+5668.97%)
Mutual labels:  webviewjavascriptbridge, jsbridge
Dsbridge Android
🌎 A modern cross-platform JavaScript bridge, through which you can invoke each other's functions synchronously or asynchronously between JavaScript and native.
Stars: ✭ 3,239 (+11068.97%)
Mutual labels:  webviewjavascriptbridge, jsbridge
JsBridge-WebViewJavascriptBridge-Sample
iOS JsBridge Solution by WebViewJavascriptBridge
Stars: ✭ 16 (-44.83%)
Mutual labels:  webviewjavascriptbridge, jsbridge
Polycube
eBPF/XDP-based software framework for fast network services running in the Linux kernel.
Stars: ✭ 217 (+648.28%)
Mutual labels:  bridge
Bridge.
Minecraft Add-on Editor | We strive to provide the best development experience possible
Stars: ✭ 193 (+565.52%)
Mutual labels:  bridge
Openmqttgateway
MQTT gateway for ESP8266, ESP32, Sonoff RF Bridge or Arduino with bidirectional 433mhz/315mhz/868mhz, Infrared communications, BLE, Bluetooth, beacons detection, mi flora, mi jia, LYWSD02, LYWSD03MMC, Mi Scale, TPMS, BBQ thermometer compatibility, SMS & LORA.
Stars: ✭ 2,413 (+8220.69%)
Mutual labels:  bridge
Cppsharp
Tools and libraries to glue C/C++ APIs to high-level languages
Stars: ✭ 2,221 (+7558.62%)
Mutual labels:  bridge
Vue-JsBridge
JsBridge for Vue
Stars: ✭ 15 (-48.28%)
Mutual labels:  jsbridge
React Native Share
Social share, sending simple data to other apps.
Stars: ✭ 2,955 (+10089.66%)
Mutual labels:  bridge
Retyped
Access 3600+ libraries from C# and let Bridge.NET compile your project into JavaScript.
Stars: ✭ 216 (+644.83%)
Mutual labels:  bridge
Mrusty
mruby safe bindings for Rust
Stars: ✭ 193 (+565.52%)
Mutual labels:  bridge
Miscord
Facebook Messenger to Discord bridge
Stars: ✭ 225 (+675.86%)
Mutual labels:  bridge
Ws Tcp Relay
A simple relay between WebSocket clients and TCP servers
Stars: ✭ 186 (+541.38%)
Mutual labels:  bridge
Gdbghidra
gdbghidra - a visual bridge between a GDB session and GHIDRA
Stars: ✭ 251 (+765.52%)
Mutual labels:  bridge
Monolog Bridge
Provides integration for Monolog with various Symfony components.
Stars: ✭ 2,238 (+7617.24%)
Mutual labels:  bridge
React Native Webview Invoke
Invoke functions between React Native and WebView
Stars: ✭ 211 (+627.59%)
Mutual labels:  bridge
Rubypython
An in-process between Ruby and Python. Soon changing repo address.
Stars: ✭ 246 (+748.28%)
Mutual labels:  bridge
React Gtk
React Native bridge for gtk desktop applications
Stars: ✭ 209 (+620.69%)
Mutual labels:  bridge
Hackpi
Hacking tool inside a Raspberry Pi zero
Stars: ✭ 218 (+651.72%)
Mutual labels:  bridge

#FMWebViewJavascriptBridge

CI Status Version License Platform

简介

FMWebViewJavascriptBridge inspired by react native 是一个轻量级的JavascriptBridge,只支持WKWebView iOS 8.0之后,与android原生调用保持一致。 image

how to Use

自定义 JavascriptInterface

  • 自定义 JavascriptInterface 类
  • 在暴露的接口前添加FM_EXPORT_METHOD宏
  • 支持的参数可以是 nil NSNull NSString NSNumber NSDictionary NSArray NSDate char int double BOOL
  • 同时支持返回值给Javascrip的回调, 回调的类型FMCallBack,支持参数同上
@implementation JavascriptInterface

FM_EXPORT_METHOD(@selector(push:))
- (void)push:(NSUInteger)one {
  [self.viewController.navigationController
      pushViewController:[WKViewController new]
                animated:YES];
  NSLog(@"test push%ld", (unsigned long)one);
}

FM_EXPORT_METHOD(@selector(pop:))
- (void)pop:(NSString *)testArray {
  [self.viewController.navigationController popViewControllerAnimated:YES];
  NSLog(@"pop array %@", testArray);
}

FM_EXPORT_METHOD(@selector(setNavTitle:response:))
- (void)setNavTitle:(NSDictionary *)userInfo response:(FMCallBack)callBack {
  self.viewController.title = userInfo[@"name"];
  callBack(@{@"name":@"carlSQ",@"age":@"26"});
}

添加接口给javascript调用

用 FMWKWebViewBridge 类中的接口addJavascriptInterface 添加接口道javascrip层

_webViewBridge = [FMWKWebViewBridge wkwebViewBridge:self.webView];
[_webViewBridge addJavascriptInterface:[JavascriptInterface new] withName:@"JavascripInterface"];

js层调用

与android原生调用保持一致,addJavascriptInterface 会在js层注入一个对象,名字是addJavascriptInterface 中设置的名字


<script>

JavascriptInterface.setNavTitle({"name" : "carl", age:"18"},function(responseData) {
                                     setNavTitle.innerHTML = "name:"+responseData.name +"  age:" + responseData.age;
                                     })

</script>

#Usage

pod 'FMWebViewJavascriptBridge', '~> 3.0.0'

Author

carl Shen

License

FMWebViewJavascriptBridge is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].