Skip to content

chanjh/GCWebContainer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GCWebContainer 是 Pandora 计划的一部分;后者让 iOS 应用可以完整运行原生 Chrome Extension。

GCWebContainer 是一个同时包含 TypeScript 和 Swift 的项目,用于连接 WKWebView 和 JS Runtime。

GitHub license

Cocoapods npm

English docs | 中文文档

使用方式

1. JS 部分

  1. 使用 NPM 安装框架
npm install --save @pandola/bridge
  1. 初始化
import launcher from '@pandola/bridge/src/launcher'
launcher();
  1. 调用 JSAPI
jsbridge('bookmarks.create', { bookmark }, callback)

2. iOS

  1. 使用 CocoaPods 安装框架
pod 'GCWebContainer', '~> 5.0'
  1. 启动 GCWebView
let webView = GCWebView();
  1. 新建一个 JSService
import Foundation
import GCWebContainer
class BookmarkService: PDBaseJSService, JSServiceHandler {
    var handleServices: [JSServiceType] {
        return [.bookmarksCreate]
    }

    func handle(message: JSServiceMessageInfo) {
        guard let params = message.params as? [String: Any] else {
            return
        }
        if message.serviceName == JSServiceType.bookmarksCreate.rawValue {
            
        }
    }
}

extension JSServiceType {
    static let bookmarksCreate = JSServiceType("bookmarks.create")
}
  1. 注册该 JSService
webView.jsServiceManager?.register(handler: BookmarkService(self, ui: webView.ui, model: webView.model))

了解更多

GCWebContainer 是 Pandora 计划的一部分,你可以通过 Pandora 和 GCWebContainerDemo 了解更多使用方式。

License

LICENSE 许可证。

About

GCWebContainer is a TypeScript and Swift framework connecting between WKWebview and JS Runtime.

Resources

License

Stars

Watchers

Forks

Packages

No packages published