GitHub Issue | n/a |
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-12-18T00:16:41.000+0000 |
Affected Version/s | Release 3.1.1 |
Fix Version/s | 2013 Sprint 13 BB, 2013 Sprint 13, Release 3.1.2, Release 3.2.0 |
Components | BlackBerry |
Labels | Blackberry, events, qe-closed-3.2.0, qe-testadded, ti.app, webview |
Reporter | Michael DeGiovanni |
Assignee | Pedro Enrique |
Created | 2013-06-12T15:26:15.000+0000 |
Updated | 2013-12-18T06:51:39.000+0000 |
*Problem*
In a local webview any titanium functionality such as
Ti.API.info('hello world');
or more important than that
Ti.API.addEventListener/fireEvent
do not work.
I have also tried placing them in a timeout like mobile web but to no avail: Ti is always undefined.
*index.xml*
<Window class="container" id="home" platform="android,blackberry">
<WebView id="mainWebView" url="/www/index.html" disableBounce="true"/>
</Window>
*index.js*
if (Ti.Platform.name === 'blackberry'){
$.mainWebView.url = 'local:///assets/www/index.html';
}
*index.html*
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>SomePage</title>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<link href="css/stylesheet.css" rel="stylesheet">
<!-- THE OFFENDING CODE SNIPPET -->
<script type="text/javascript">
window.onload = function(){
setTimeout(function(){
alert(typeof(Ti));
Ti.API.info('in timeout file');
Ti.API.fireEvent('someEvent');
},2000);
};
</script>
<script data-main="js/main" src="js/libs/require.js"></script>
</head>
<body>
</body>
</html>
Can we get a snippet of offending code? Ti.API.info is available but I'm not sure what in web view means.
index.xml has the following:
looking at the blackberry documentation and the github Tiblackberry repository, I think this is still missing for two way interaction between the webview and the app on titanium. "You can interact with JavaScript executing on the page by using postMessage() and connecting to the messageReceived() signal. JavaScript can communicate back by using the "navigator.cascades.postMessage()" function and storing a message handler in the "navigator.cascades.onmessage" property." (http://developer.blackberry.com/cascades/reference/bb__cascades__webview.html)
Based on the android binding.js, I've added the following gist that needs to be injected on a local webview: https://gist.github.com/anonymous/5772986 .Obviously the interface between the titanium app has to be added. Note that in that gist the logging part has been left our (in Android it is through the webviews addJavascriptInterface )
Thanks Michael, I'm working on this.
PR: https://github.com/appcelerator/titanium_mobile_blackberry/pull/111
Nice.
thanks!
Attached sample code
Verified the fix & the fix works as expected.Thus closing. Environment: Appcel Studio : 3.1.2.201308082014 Ti SDK : 3.1.2.v20130809141556 Mac OSX : 10.8.4 Alloy : 1.2.0-alpha6 CLI - 3.1.2-alpha win 7 Win 8 Z10 BB simulator : 10.0.10.822 Z10 device running 10.0.10.88 Q10 Simulator : 10.1.0.1720 Q10 Dev alpha C device running 10.1.0.138
[~penrique] Appcelerator Studio, build: 3.2.0.201312162210 Titanium SDK, build: 3.2.0.v20131216191854 CLI 3.2.0-cr3 Alloy 1.3.0-cr2 BBZ10 10.1.0 Tested .zip and webview header value "something else" does not change to "am changed again" as per code.
Cause was due to a change in the Ti.App module. PR for master: https://github.com/appcelerator/titanium_mobile_blackberry/pull/199 PR for 3.2.x: https://github.com/appcelerator/titanium_mobile_blackberry/pull/200
Tested Environment: Appcelerator Studio: 3.2.0.201312171913 SDK:3.2.0.v20131217190633 alloy: 1.3.0-cr2 acs: 1.0.10 npm: 1.3.2 titanium: 3.2.0-cr3 titanium-code-processor: 1.1.0-cr2 OS: Mac OSX 10.9 Blackberry Z10(v 10.0.10.261) Used with the sample code attached. Got the expected result as per code. 1)Clicking on 'click here' button. Webview header with id header_2 changes its title as 'something else' and also button with having title 'fire event' also changes to 'something else'. Console also gets logged printed with "Hello World!" 2)Then on clicking 'something else' title button. Again the Webview header with id header_2 changes its title as 'prop_1' Hence closing the issue as working fine.