h5 2
Showing
2 changed files
with
17 additions
and
5 deletions
| ... | @@ -94,12 +94,11 @@ layer.open({ | ... | @@ -94,12 +94,11 @@ layer.open({ |
| 94 | 94 | ||
| 95 | 95 | ||
| 96 | if(isAndroid || isiOS) { | 96 | if(isAndroid || isiOS) { |
| 97 | |||
| 97 | function setupWebViewJavascriptBridge(callback) { | 98 | function setupWebViewJavascriptBridge(callback) { |
| 98 | layer.open({ | 99 | |
| 99 | content: window.WebViewJavascriptBridge , | ||
| 100 | time: 2 | ||
| 101 | }) | ||
| 102 | if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); } | 100 | if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); } |
| 101 | if(isiOS){ | ||
| 103 | if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); } | 102 | if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); } |
| 104 | window.WVJBCallbacks = [callback]; | 103 | window.WVJBCallbacks = [callback]; |
| 105 | var WVJBIframe = document.createElement('iframe'); | 104 | var WVJBIframe = document.createElement('iframe'); |
| ... | @@ -107,9 +106,22 @@ if(isAndroid || isiOS) { | ... | @@ -107,9 +106,22 @@ if(isAndroid || isiOS) { |
| 107 | WVJBIframe.src = 'https://__bridge_loaded__'; | 106 | WVJBIframe.src = 'https://__bridge_loaded__'; |
| 108 | document.documentElement.appendChild(WVJBIframe); | 107 | document.documentElement.appendChild(WVJBIframe); |
| 109 | setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0) | 108 | setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0) |
| 109 | } else if (isAndroid) { | ||
| 110 | document.addEventListener('WebViewJavascriptBridgeReady', function (event) { | ||
| 111 | callback(WebViewJavascriptBridge) | ||
| 112 | }, false) | ||
| 113 | } | ||
| 114 | |||
| 110 | } | 115 | } |
| 111 | setupWebViewJavascriptBridge(function(bridge) { | 116 | setupWebViewJavascriptBridge(function(bridge) { |
| 117 | layer.open({ | ||
| 118 | content: bridge , | ||
| 119 | time: 2 | ||
| 120 | }) | ||
| 112 | if(isAndroid) { | 121 | if(isAndroid) { |
| 122 | bridge.init(function (message, responseCallback) { | ||
| 123 | responseCallback({'Javascript Responds': 'Wee!'}) | ||
| 124 | }) | ||
| 113 | // appClient = new AppClient(bridge, isAndroid); | 125 | // appClient = new AppClient(bridge, isAndroid); |
| 114 | } | 126 | } |
| 115 | if (isiOS) { | 127 | if (isiOS) { | ... | ... |
| ... | @@ -174,7 +174,7 @@ angular.module('myApp') | ... | @@ -174,7 +174,7 @@ angular.module('myApp') |
| 174 | window.WebViewJavascriptBridge.callHandler('getGPS', function (res) { | 174 | window.WebViewJavascriptBridge.callHandler('getGPS', function (res) { |
| 175 | layer.open({ | 175 | layer.open({ |
| 176 | content: res, | 176 | content: res, |
| 177 | time: 10 | 177 | time: 5 |
| 178 | }); | 178 | }); |
| 179 | }, '') | 179 | }, '') |
| 180 | 180 | ... | ... |
-
Please register or sign in to post a comment