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

How can I get feedback when the js method does not exist? #394

Open
ApesTalk opened this issue Nov 21, 2019 · 4 comments
Open

How can I get feedback when the js method does not exist? #394

ApesTalk opened this issue Nov 21, 2019 · 4 comments

Comments

@ApesTalk
Copy link

When i use WKWebViewJavascriptBridge call js method from iOS like this:

[self.bridge callHandler:@"notExistJsMethod" data:nil responseCallback:^(id responseData) {
        //can not get any response here
 }];

If sometimes the js method does not exist, i can not get any callback to know there is something wrong. If I can get feedback, I can do some default processing.

@housenkui
Copy link

had refactor the WebViewJavascriptBridge .
If you are in trouble.You can try this.
Download Address:
https://github.com/housenkui/WebViewJavascriptBridge
More light and more simple to use. 10 mins will enough to completed your demand.

@housenkui
Copy link

@ApesTalk

@Wbqqqq
Copy link

Wbqqqq commented May 19, 2020

i have same issue @ApesTalk

@ThisIszas
Copy link

Search "console.log("WebViewJavascriptBridge: WARNING: no handler for message from ObjC:", message);" inside WebViewJavascriptBridge_JS.m and modify JS code like this:

 if (!handler) {
      console.log("WebViewJavascriptBridge: WARNING: no handler for message from ObjC:", message);
      if (message.callbackId) {
           var callbackResponseId = message.callbackId;
           _doSend({ handlerName:"", responseId:callbackResponseId, responseData:{"error": "jsHandlerNotFound"} });
      }                  
 }

This change require you provide a responseCallback or you cannot receive error callback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants