diff --git a/Example Apps/ExampleApp.html b/Example Apps/ExampleApp.html index 06e7dc8a..7dbfae1a 100644 --- a/Example Apps/ExampleApp.html +++ b/Example Apps/ExampleApp.html @@ -1,19 +1,37 @@ + - + -

WebViewJavascriptBridge Demo

- -
+ var uniqueId = 1 + function log(message, data) { + var log = document.getElementById('log') + var el = document.createElement('div') + el.className = 'logLine' + el.innerHTML = uniqueId++ + '. ' + message + ':
' + JSON.stringify(data) + if (log.children.length) { log.insertBefore(el, log.children[0]) } + else { log.appendChild(el) } + } + + bridge.registerHandler('testJavascriptHandler', function(data, responseCallback) { + log('ObjC called testJavascriptHandler with', data) + var responseData = { 'Javascript Says':'Right back atcha!' } + log('JS responding with', responseData) + responseCallback(responseData) + }) + + document.body.appendChild(document.createElement('br')) + + var callbackButton = document.getElementById('buttons').appendChild(document.createElement('button')) + callbackButton.innerHTML = 'Fire testObjcCallback' + callbackButton.onclick = function(e) { + e.preventDefault() + log('JS calling handler "testObjcCallback"') + bridge.callHandler('testObjcCallback', {'foo': 'bar'}, function(response) { + log('JS got response', response) + }) + } + }) + +
+
W3School
diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index ee75de48..20a76eb4 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -13,6 +13,9 @@ Pod::Spec.new do |s| s.ios.private_header_files = 'WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h' s.osx.source_files = 'WebViewJavascriptBridge/*.{h,m}' s.osx.private_header_files = 'WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h' + s.ios.exclude_files = 'WebViewJavascriptBridge/WebViewJavascriptBridge.{h,m}' + s.osx.exclude_files = 'WebViewJavascriptBridge/WebViewJavascriptBridge.{h,m}' + s.frameworks = 'WebKit' s.ios.frameworks = 'UIKit', 'WebKit'