# webview **Repository Path**: azazie_specs/webview ## Basic Information - **Project Name**: webview - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-04-21 - **Last Updated**: 2024-03-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # LBWebView [![CI Status](http://img.shields.io/travis/408939786@qq.com/LBWebView.svg?style=flat)](https://travis-ci.org/408939786@qq.com/LBWebView) [![Version](https://img.shields.io/cocoapods/v/LBWebView.svg?style=flat)](http://cocoapods.org/pods/LBWebView) ## Example To run the example project, clone the repo, and run `pod install` from the Example directory first. 使用方式如下: ``` LBWebView *webView = [[LBWebView alloc] initWithFrame:CGRectInset(self.view.frame, 0, 64) delegate:self]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://127.0.0.1/jsBridgeTest"]]; [webView loadRequest:request]; ``` ##实现细节 ###navigator.userAgent `navigator.userAgent`值如下: ``` Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Mobile/14E269 LebbayApp/1.0 (iPhone; iOS 10.3; Scale/3.00); ``` 其中包括App名字、手机平台名字(`iPhone`或`Android`)、App版本、系统版本。 ###JS调用方式 ``` const url = 'lebbay://www.lebbay.com/native/openTel?tel=18888888888'; const parameter = { "method": method, "key": key, //用于唯一确认一次调用过程 "callback":"openTelCallback", "parameters":{} //参数 } callNative(JSON.stringify(parameter)); function callNative(parameter) { window.webkit.messageHandlers.lebbay.postMessage(parameter); //Android //AndroidLebbay.postMessage(parameter); } ``` 其中`lebbay`是由业务层指定,`method `为需要调用的方法,`callback `为回调方法,该回调由应用层进行调用,应用层中针对需要回调的业务,各组件独自完成。 使用细节请见[WebView与原生交互JS实现(待补充)]() `parameters`根据具体的业务场景,传入`json`对象 备注:JS调用原生,如果需要原生回调JS的,且callback未设置值,均直接回调`bridge_${method}(${response})`。该逻辑的实现在业务层。 ## Requirements ``` iOS >= 9.0 ``` ## Installation LBWebView is available through [CocoaPods](http://cocoapods.org). To install it, simply add the following line to your Podfile: ```ruby pod "LBWebView" ``` ## Author 吴仕海, shwu1@i9i8.com ## License LBWebView is available under the MIT license. See the LICENSE file for more info.