Skip to content

基于jsbridge,处理外部设置WebViewClient导致jsbridge失效的问题

Notifications You must be signed in to change notification settings

liulingfeng/CommonWebview

Repository files navigation

CommonWebview

jsbridge源码 https://github.com/lzyzsd/JsBridge

1.基于jsbridge,处理外部设置WebViewClient导致jsbridge失效的问题
2.隔离jsbridge的实现

使用说明

interface WebApi {
    @H5ToNative(methodName = "submitFromWeb")
    fun submitFromWeb(@Field returnData: String, @CallBack h5CallBack: H5CallBack)

    @NativeToH5(methodName = "functionInJs")
    fun functionInJs(@Field responseData: String, @CallBack h5CallBack: H5CallBack)
}

业务方调用

 val webApi = H5Retrofit.getInstance(commonFragment?.getWebView()).create(WebApi::class.java)
 webApi?.functionInJs(Gson().toJson(user),object :H5CallBack{
      override fun callBack(data: String) {
          Log.e("德玛","h5返回数据$data")
       }
     })
 webApi?.submitFromWeb("submitFromWeb exe, response data 中文 from Java",object :H5CallBack{
       override fun callBack(data: String) {
           Log.e("德玛","h5返回参数$data")
        }
      })

About

基于jsbridge,处理外部设置WebViewClient导致jsbridge失效的问题

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published