Skip to content

lefex/SYJSBridge

Repository files navigation

An iOS modern bridge for sending messages between Objective-C and JavaScript in WKWebView. Include FE and iOS.

The project is in the beta phase and is being used in my own projects.

logo

How to run

You should install node before run SYBridge.

# clone the project
git clone git@github.com:lefex/SYJSBridge.git
# cd to web catagory,the iOS page source
cd web
# run npm install to  install dependency
npm install
# run webserver
npm run start

Documentation

Docs Detail

npm run docs
npm run docs:dev

Use in FE

sy-webview-bridge provide a system plugin that can show a modal alert in App. This code to show a modal alert and will receive a success callback when user click OK or Cancel button.

sy.system.showModal({
    title: 'SYWebViewBridge',
    content: 'An iOS modern bridge for sending messages between Objective-C and JavaScript in WKWebView.',
    showCancel: true,
    cancelText: 'Cancel',
    confirmText: 'OK',
    // success
    success: function(res) {
        if (res.confirm) {
            // user click OK button
        }
        else {
            // user click Cancel button
        }
    },
    // fail
    fail: function(err) {
        console.log(err);
    },
    // call when success or fail
    complete: function(res) {
        console.log(res);
    }
});

more docs

Use in iOS

You need to download the project SYWebViewBridge to use in iOS。

Questions

If you have any questions, you can pay attention to my wechat official account 素燕.

Contribution

Please make sure to read the Contributing Guide before making a pull request.

License

MIT

Copyright (c) 2020-present, Suyan Wang

About

An iOS modern bridge for sending messages between Objective-C and JavaScript in WKWebView. Include FE and iOS.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published