[ 
https://issues.apache.org/jira/browse/CB-6746?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14008943#comment-14008943
 ] 

Nick Eaket commented on CB-6746:
--------------------------------

Thanks for looking at this ticket.  Might want to change my suggested fix to 
'flush' messages instead of actually consuming them at app startup, incase of 
unexpected side effects.  No, sendJavascript() was not called from a core 
plugin.  I discovered the use in a new keyboard plugin, 
https://github.com/driftyco/ionic-plugins-keyboard .  Should the 
`CordovaWebView.sendJavascript()` method be deprecated, to hopefully avoid its 
use in the future?

> Android's JS->Native ONLINE_EVENT does not work when cordova-js is not loaded 
> before the first message
> ------------------------------------------------------------------------------------------------------
>
>                 Key: CB-6746
>                 URL: https://issues.apache.org/jira/browse/CB-6746
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: CordovaJS
>    Affects Versions: 3.3.0
>         Environment: Android 
>            Reporter: Nick Eaket
>            Priority: Minor
>
> Currently if the Cordova-js Android Native->JS message handler registers on 
> the 'online'/'offline event.  If a Native message is sent using 
> CordovaWebView.sendJavascript(...) and Cordova-js is currently not loaded, 
> the web view will remain in the 'offline' state.  When Cordova-JS is finally 
> loaded, sending another message from Native->JS will continue to fill up the 
> message queue.  Cordova-JS will currently never see if the Native code has 
> new messages.
> Steps to reproduce:
> 1. Create a new Cordova Android app
> 2. Have the app load a web page that does not load cordova-js
> 3. Have a Cordova Native plugin send a JavaScript message to the app.  
> (expected to be ignored, since cordova-js is not loaded)
> 4.  Navigate to a second web page that does load cordova-js
> 5. Repeat step 3.
> Expected:
> Cordova-js should receive the message from step 5
> Suggested Fix:
> Add a call to 'pollOnceFromOnlineEvent()' after the 'deviceready' event.  
> The call could potentially go here.  
> https://github.com/apache/cordova-js/blob/master/src/android/exec.js#L266



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to