Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16478] Ability to fire event from a web view when the contents are loaded from a hosted site (e.g. non local resource)

GitHub Issuen/a
TypeNew Feature
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
LabelswebView
ReporterLeor Brenman
AssigneeUnknown
Created2014-02-19T18:20:46.000+0000
Updated2018-02-28T20:03:17.000+0000

Description

Ability to fire event from a web view when the contents are loaded from a hosted site (e.g. non local resource) If your web contents are stored locally in the assets folder, then the Ti.App.fireEvent works and the titanium app can respond. e.g.: Ti.App.fireEvent('app:fromWebView', { message: 'event fired from WebView, handled in Titanium' }); If the web contents are stored on a web site, then the event doesn't fire. This has come up twice today, once with Scott's and once with Louisville, Gas & Electric. Both prospects have existing HTML5 web apps that they would want to use with an Appcelerator container. Event firing is useful for normal native/web view interaction as well as for leveraging Analytics and Breadcrumbs for the web view by firing an event to the native app and having the native app fire an analytics feature event and breadcrumb events. I have provided a sample app where you can switch between local and remote html resources (settable in index.xml). Screen shots are also attached. After entering a stock symbol (AAPL) in the web view and clicking submit, the web view fires an event. The container has an event listener for the even and displays an alert. If the web resources are local this works. If the web resources are remote, it does not. We hope to get a workaround or a solution for this. Is there some javascript library that can be added to the remote web app so that Ti.App.fireEvent will work

Attachments

FileDateSize
app.zip2014-02-19T18:20:47.000+00003325942
notWorking_remote.png2014-02-19T18:20:47.000+0000139494
remoteWebFireEvent_Example.zip2014-02-20T21:46:04.000+00003371827
working_local.png2014-02-19T18:20:47.000+0000120135

Comments

  1. Leor Brenman 2014-02-19

    Someone from the community did find dome hack/workaround: http://developer.appcelerator.com/question/115911/titanium-javascript-in-webviews-for-remote-urls
  2. Leor Brenman 2014-02-20

    Bert created a workaround that resolves the issue for now (sample attached) but it is a little cumbersome so it would be nice to have this be part of the platform.
  3. Leor Brenman 2014-02-20

    Workaround sample

JSON Source