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

returning object from obj c to js on button click #29

Closed
KarthickR opened this issue Dec 10, 2012 · 3 comments
Closed

returning object from obj c to js on button click #29

KarthickR opened this issue Dec 10, 2012 · 3 comments

Comments

@KarthickR
Copy link

Hi marcus,

i want the handler to be called only when the getNameListBttnTapped method is triggered following is the script

<script> var bridge function getNameListBttnTapped(){ alert('inside getNameListBttnTapped') bridge.callHandler('testObjcCallback', {'foo': 'bar'}, function(response) { log('JS got response', response) alert(response) }) } window.onerror = function(err) { log('window.onerror: ' + err) } document.addEventListener('WebViewJavascriptBridgeReady', onBridgeReady, false) function onBridgeReady(event) { bridge = event.bridge } </script>

Here is the code, i have used for registering the handler.

[_bridge registerHandler:@"testObjcCallback" handler:^(id data, WVJBResponseCallback responseCallback) {
NSLog(@"testObjcCallback called: %@", data);
responseCallback(@"Response from testObjcCallback");
}];

when i tap on the GetNameList button handler is called and the response is sent to webview javascript bridge, but the function(response) is not triggered.Please help me to solve the issue.

@marcuswestin
Copy link
Owner

Hi @KarthickR,

I see you closed the issue - does this mean you solved it?

Cheers!
Marcus

@marcuswestin
Copy link
Owner

If you launch the ExampleApp that comes with the repo, you'll find example code that does exactly what you want and works. I suggest you start with that code and make changes to it.

Cheers!
Marcus

@KarthickR
Copy link
Author

Hi marcus,

Thank you very much, i have solved the issue.

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

2 participants