GithubHelp home page GithubHelp logo

smallbuer / jsbridge-android Goto Github PK

View Code? Open in Web Editor NEW
229.0 7.0 39.0 1.64 MB

A solution for safe and fast interaction between js and native,it's minimum support API 14;

License: Apache License 2.0

HTML 5.01% Kotlin 12.27% Java 58.18% JavaScript 24.55%
jsbridge jsbind jsapi

jsbridge-android's Issues

eval-unsafe

代码里调用了eval() 现在很多domain都拒绝使用eval了,这个绕不过去,建议替换

X5WebView vue项目有时无法调用到jsbridge

bridgeTiny.webViewLoadJs((IWebView) webView);
问题:
X5WebView打开Vue项目, 部分方法需要在资源未加载完成前调用,在onPageFinished注入时无法获取到桥,因此修改了的注入位置-->onPageStarted|onLoadResource|shouldOverrideUrlLoading|onPageFinished

这样处理后可以调用到桥,但是出现新的问题。部分手机依然出现无法获取到桥 或者 有时可以有时不可以的现象 ,即使页面资源加载完后也无法调用到桥,有时切换网络重新加载页面就可以调用到。不知道是哪里的问题???

关于WebViewJavascriptBridge名称的问题

iOS使用的bridge名称是WKWebViewJavascriptBridge,想和他们兼容一下,能不能把js串里面的所有WebViewJavascriptBridge都改成WKWebViewJavascriptBridge?然后在html里边调用window.WKWebViewJavascriptBridge

微信h5支付异常

这个会让微信h5支付异常,会让微信的回调redirect_url无法重定向。

无法注册单个Handler

我想在Activity中单独添加个Handler,源码中初始化BridgeTiny的时候已经添加了所有的Handler, 想在Activity中单独添加该怎么做呢(weview和Activity在用一个页面的需求)

BridgeWebViewClient未public

BridgeWebViewClient我有代码需要在WebViewClient操作,但是这个方法未public,wo只能把代码考出来重写

implement不下来

implementation 'com.smallbuer:jsbridge:1.0.2'
ERROR: Failed to resolve: jsbridge
Affected Modules: app

混淆后js无法被调用

看源码 好像是 gson解析的类被混淆了

/**
* 分发message 必须在主线程才分发成功
*
* @param message Message
*/
public void dispatchMessage(Object message) {

    String messageJson = new Gson().toJson(message);
    //escape special characters for json string  为json字符串转义特殊字符
    messageJson = messageJson.replaceAll("(\\\\)([^utrn])", "\\\\\\\\$1$2");
    messageJson = messageJson.replaceAll("(?<=[^\\\\])(\")", "\\\\\"");
    messageJson = messageJson.replaceAll("(?<=[^\\\\])(\')", "\\\\\'");
    messageJson = messageJson.replaceAll("%7B", URLEncoder.encode("%7B"));
    messageJson = messageJson.replaceAll("%7D", URLEncoder.encode("%7D"));
    messageJson = messageJson.replaceAll("%22", URLEncoder.encode("%22"));
    String javascriptCommand = String.format(BridgeUtil.JS_HANDLE_MESSAGE_FROM_JAVA, messageJson);

    BridgeLog.d(TAG,"javascriptCommand->"+javascriptCommand);

    // 必须要找主线程才会将数据传递出去 --- 划重点
    if (Thread.currentThread() == Looper.getMainLooper().getThread()) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT&&javascriptCommand.length()>=BridgeUtil.URL_MAX_CHARACTER_NUM) {
            mWebView.evaluateJavascript(javascriptCommand,null);
        }else {
            mWebView.loadUrl(javascriptCommand);
        }
    }
}

CallBackFunction只能用一次

请问js调用Android端代码后的CallBackFunction回调,是只能用一次的吗?返回一次结果之后再调用CallBackFunction就收不到结果了

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.