GithubHelp home page GithubHelp logo

chanjh / gcwebcontainer Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 139 KB

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

License: MIT License

Swift 65.58% Ruby 2.07% HTML 0.75% JavaScript 4.30% TypeScript 27.29%

gcwebcontainer's Introduction

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 许可证。

gcwebcontainer's People

Contributors

chanjh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.