GithubHelp home page GithubHelp logo

hybrid-bridge's Introduction

混合应用协议桥

demo

web读取native信息

HybridBridge.wait('/getUserInfo', {userid:1}, function(user){
  // do something
});

web侦听native事件

HybridBridge.listen('/topRightButton',{}, function(){
  // do something
});

ios

webView stringByEvaluatingJavaScriptFromString:@"HybridBridge.dispatchWait('/getUserInfo', {})"

android

webView.loadUrl("HybridBridge.dispatchWait('/getUserInfo',{user})");

API

/* 执行客户端方法,并需要返回数据
args     type      description           example
url      string    与客户端协定的协议url    '/getUserinfo'
options  object    与客户端协定的协议参数    {userid:'1'}
callback function  客户端返回数据时的处理程序 function(url, data){}
*/
HybridBridge.wait(url, options, callback);
/* 监听客户端某种事件,并需要返回数据
args     type      description           example
url      string    与客户端协定的协议url    '/getUserinfo'
options  object    与客户端协定的协议参数    {userid:'1'}
callback function  客户端返回数据时的处理程序 function(url, data){}
*/
HybridBridge.listen(url, options, handler);
/* 执行客户端方法,不需要返回数据
args     type      description           example
url      string    与客户端协定的协议url    '/login'
options  object    与客户端协定的协议参数    {}
*/
HybridBridge.invoke(url, options);
/* 客户端返回数据
args     type      description           example
url      string    与客户端协定的协议url    '/getUserinfo'
options  object    与客户端协定的协议参数    {userid:'1'}
callback function  客户端返回数据时的处理程序 function(url, data){}
*/
HybridBridge.dispatchWait(url, data);
/* 客户端派发事件
args     type      description           example
url      string    与客户端协定的协议url    '/getUserinfo'
options  object    与客户端协定的协议参数    {userid:'1'}
callback function  客户端返回数据时的处理程序 function(url, data){}
*/
HybridBridge.dispatchListener(url,data);

依赖库

  • base64

hybrid-bridge's People

Contributors

meetyou-team avatar

Watchers

cigoe avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.