All Projects → Lision → Wkwebviewjavascriptbridge

Lision / Wkwebviewjavascriptbridge

Licence: mit
🌉 A Bridge for Sending Messages between Swift and JavaScript in WKWebViews.

Programming Languages

javascript
184084 projects - #8 most used programming language
swift
15916 projects
js
455 projects

Projects that are alternatives of or similar to Wkwebviewjavascriptbridge

Mybrowser
我的浏览器,基于WKWebView实现的一个iOS浏览器,实现了无图模式、广告拦截、多窗口、扫描二维码、收藏夹/历史、无痕浏览、夜间模式等功能...
Stars: ✭ 127 (-85.28%)
Mutual labels:  wkwebview, webkit
FlexHybridApp-iOS
WebView bridge interface with Promise pattern
Stars: ✭ 17 (-98.03%)
Mutual labels:  wkwebview, bridge
Hybridpagekit
A high-performance、high-extensibility、easy integration framework for Hybrid content page. Support most content page types of News App.
Stars: ✭ 1,101 (+27.58%)
Mutual labels:  hybrid, wkwebview
Macdriver
Native Mac APIs for Go
Stars: ✭ 3,582 (+315.06%)
Mutual labels:  bridge, webkit
React Native Webview Invoke
Invoke functions between React Native and WebView
Stars: ✭ 211 (-75.55%)
Mutual labels:  bridge, hybrid
Macpin
a webapp container & site specific browser made from WebKit.swift and JavaScriptCore
Stars: ✭ 289 (-66.51%)
Mutual labels:  wkwebview, webkit
Luna Studio
Looking for Luna, the WYSIWYG language for data processing? Development has moved 👉
Stars: ✭ 602 (-30.24%)
Mutual labels:  hybrid
Multi
Create a custom, lightweight macOS app from a group of websites
Stars: ✭ 755 (-12.51%)
Mutual labels:  webkit
Mui Kidapp
基于 MUI 构建一个具有 90 +页面的APP应用
Stars: ✭ 551 (-36.15%)
Mutual labels:  hybrid
Playwright
Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
Stars: ✭ 31,513 (+3551.56%)
Mutual labels:  webkit
Mdviewer
Minimalistic Markdown viewer/converter with built-in Css stylesheets support.
Stars: ✭ 26 (-96.99%)
Mutual labels:  webkit
Ios tips
iOS的一些示例,持续更新中:1、AVFoundation 高仿微信相机拍摄和编辑 2、AVFoundation 人脸检测、实时滤镜、音视频编解码、GPUImage框架的使用等音视频相关内容 3、OpenGLES 4、LeetCode算法练习 5、iOS Crash防护和APM监控 6、WKWebView相关的内容 等........
Stars: ✭ 896 (+3.82%)
Mutual labels:  wkwebview
Hmq
High performance mqtt broker
Stars: ✭ 722 (-16.34%)
Mutual labels:  bridge
React Native Wkwebview
WKWebview Component for React Native
Stars: ✭ 622 (-27.93%)
Mutual labels:  wkwebview
Axwebviewcontroller
AXWebViewController is a webViewController to browse web content inside applications. It’s a lightweight controller on iOS platform based on WKWebView (UIWebView would be the base Kit under iOS 8.0). It added navigation tool bar to refresh, go back, go forward and so on. It support the navigation style on WeChat. It is a simple-using and convenient web view controller using inside applications.
Stars: ✭ 770 (-10.78%)
Mutual labels:  webkit
Manet
Website screenshot service powered by Node.js, SlimerJS and PhantomJS
Stars: ✭ 570 (-33.95%)
Mutual labels:  webkit
Mobileblazorbindings
Experimental Mobile Blazor Bindings - Build native and hybrid mobile apps with Blazor
Stars: ✭ 893 (+3.48%)
Mutual labels:  hybrid
Trip
移动前端开发经验指南
Stars: ✭ 550 (-36.27%)
Mutual labels:  hybrid
Tysnapshotscroll
一句代码保存截图,将 UIScrollView UITableView UICollectionView UIWebView WKWebView 网页 保存 为 长图 查看。Save the scroll view page as an image,support UIScrollView,UITableView,UICollectionView,UIWebView,WKWebView.(Support iOS13)
Stars: ✭ 709 (-17.84%)
Mutual labels:  wkwebview
Lin
Parser for contract bridge "lin" notation
Stars: ✭ 5 (-99.42%)
Mutual labels:  bridge

language  Carthage compatible  License MIT  Support  CocoaPods  Build Status  CocoaPods

中文介绍

This project is inspired by WebViewJavascriptBridge!

What Can WKWebViewJavascriptBridge Do?

You can write hybrid modules in just a few lines of code by using WKWebViewJavascriptBridge without the need to be concerned with the underlying messaging implementation.

Why Only Support WKWebView?

Advantages of WKWebView

It is well known that WKWebView loads web pages faster and more efficiently than UIWebView, and also doesn't have as much memory overhead for you.

Under the current timeline, most iOS apps only support iOS 9.0+.

UIWebView Cross-Domain Access Vulnerability

The reason for the iOS platform cross-domain access vulnerability is due to UIWebView turning on the WebKitAllowUniversalAccessFromFileURLs and WebKitAllowFileAccessFromFileURLs options.

WKWebView default allowFileAccessFromFileURLs and allowUniversalAccessFromFileURLs option is false.

Features

  • Swift Support: Swift 3.2 ~ 5 Support.
  • High Performance: The messaging performance is higher than intercept requests.
  • High Speed: No need to consider alert box safety timeout.
  • Lightwight: This framework contains only 3 files.
  • Non-intrusive: There is no need to make the webview class inherit from other base class.

Usage

1. Instantiate WKWebViewJavascriptBridge with a WKWebView:

bridge = WKWebViewJavascriptBridge(webView: webView)

2. Register a Handler in Native, and Call a JS Handler:

bridge.register(handlerName: "testiOSCallback") { (parameters, callback) in
    print("testiOSCallback called: \(String(describing: parameters))")
    callback?("Response from testiOSCallback")
}

bridge.call(handlerName: "testJavascriptHandler", data: ["foo": "before ready"], callback: nil)

3. Copy and Paste setupWKWebViewJavascriptBridge into Your JS:

function setupWKWebViewJavascriptBridge(callback) {
    if (window.WKWebViewJavascriptBridge) { return callback(WKWebViewJavascriptBridge); }
    if (window.WKWVJBCallbacks) { return window.WKWVJBCallbacks.push(callback); }
    window.WKWVJBCallbacks = [callback];
    window.webkit.messageHandlers.iOS_Native_InjectJavascript.postMessage(null)
}

4. Finally, Call setupWKWebViewJavascriptBridge and then Use The Bridge to Register Handlers and Call Native Handlers:

setupWKWebViewJavascriptBridge(function(bridge) {

	/* Initialize your app here */

	bridge.registerHandler('testJavascriptHandler', function(data, responseCallback) {
		console.log('iOS called testJavascriptHandler with', data)
		responseCallback({ 'Javascript Says':'Right back atcha!' })
	})

	bridge.callHandler('testiOSCallback', {'foo': 'bar'}, function(response) {
		console.log('JS got response', response)
	})
})

Installation

Cocoapods

  1. Add pod 'WKWebViewJavascriptBridge', '~> 1.2.0' to your Podfile.
  2. Run pod install or pod update.
  3. Add import WKWebViewJavascriptBridge.

Carthage

  1. Add github "Lision/WKWebViewJavascriptBridge" ~> 1.2.0 to your Cartfile.
  2. Run carthage update --platform ios.
  3. Add the WKWebViewJavascriptBridge framework to your project.

Manually

Either clone the repo and manually add the Files in WKWebViewJavascriptBridge.

Requirements

This framework requires iOS 9.0+ and Xcode 9.0+.

Contact

License

WKWebViewJavascriptBridge is provided under the MIT license. See LICENSE file for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].