webview

1、了解webview:  参考链接

2、H5与App native的交互:

  a、目前javascript和客户端(后面统称native)交互的常见方式有两种,一种是通过JSBridge(杭州办事app就是通过这种方式进行交互的)的方式,另一种是通过schema的方式。

            if (window.jsbridge){
                window.jsbridge.add(t);
            }
            else {
                var r = "ListItem" + (new Date()).getTime();
                this.readyList[r] = t
            }

  b、晚上看到还有一种方式,但是 还 不了解,有时间在研究。  https://blog.csdn.net/lyyo_cd/article/details/84304864

    安卓中:

     jsObj.call('dadsf')

    ios中:

    window.webkit.messageHandlers.jsObj.postMessage('dafdfadf')

3、不同环境的 userAgent:(先把userAgent都变成小写的,toLowerCase() 在进行判断)

  a、微信(安卓):

Mozilla/5.0 (Linux; Android 7.0; M3 Max Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045131 Mobile Safari/537.36 MMWEBID/5722 MicroMessenger/7.0.14.1660(0x27000E37) Process/tools NetType/WIFI Language/zh_CN ABI/arm64 WeChat/arm64

  b、微信(苹果):

Mozilla/5.0 (iPhone; CPU iPhone OS 13_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.12(0x17000c2d) NetType/WIFI Language/zh_CN

  c、安卓手机浏览器:

Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.96 Safari/537.36 MZBrowser/8.2.1

  d、苹果手机浏览器:

Mozilla/5.0 (iPhone; CPU iPhone OS 13_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 Mobile/15E148 Safari/604.1

  e、微信小程序(安卓):

 mozilla/5.0 (iphone; cpu iphone os 10_3_1 like mac os x) applewebkit/603.1.3 (khtml, like gecko) version/10.0 mobile/14e304 safari/602.1 wechatdevtools/1.02.1911180 micromessenger/7.0.4 language/zh_cn webview/100_13 webdebugger miniprogramhtmlwebview miniprogram port/25440

 

5、

posted @ 2019-04-06 22:24  吴飞ff  阅读(221)  评论(0编辑  收藏  举报