Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For Android Platform #1

Closed
wendux opened this issue Jan 29, 2018 · 2 comments
Closed

For Android Platform #1

wendux opened this issue Jan 29, 2018 · 2 comments
Labels

Comments

@wendux
Copy link

wendux commented Jan 29, 2018

WebViewJavascriptBridge For Android: https://github.com/wendux/WebViewJavascriptBridge .

This Android version project is a mirror of marcuswestin/WebViewJavascriptBridge(Object-c) and Lision/WKWebViewJavascriptBridge(Swift) , so there are some similarities , such as API design, native code, and the example demo. For the Javascript code, it is exactly the same.

Welcome suggestions and criticism !

@Lision

@Lision
Copy link
Owner

Lision commented Jan 29, 2018

Hi~ @wendux
Good Job!
Emmmmm... But this framework has made some changes.
For example, do not rely on intercept requests for messaging.
So... For the Javascript code, there are also some minor changes.

@wendux
Copy link
Author

wendux commented Jan 29, 2018

If want to be compatible with WebViewJavascriptBridge For Android, the users should modify the setupWebViewJavascriptBridge to :

function setupWebViewJavascriptBridge(callback) {
    var bridge=window.WebViewJavascriptBridge||window.WKWebViewJavascriptBridge
	if (bridge) { return callback(bridge); }
	var callbacks=window.WVJBCallbacks||window.WKWVJBCallbacks
	if (callbacks) { return callbacks.push(callback); }
	window.WVJBCallbacks=window.WKWVJBCallbacks = [callback];
	if(window.WKWebViewJavascriptBridge){
	  window.webkit.messageHandlers.iOS_Native_InjectJavascript.postMessage(null)
	}
}

The code above can still run right on Android.

@Lision Lision added the Android label Sep 10, 2018
@Lision Lision closed this as completed May 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants