CB-6851 Deprecate WebView.sendJavascript()

This commit is contained in:
Andrew Grieve 2014-06-08 22:47:41 -04:00
parent 32e07c22d0
commit b407641049

View File

@ -557,10 +557,25 @@ public class CordovaWebView extends WebView {
/**
* Send JavaScript statement back to JavaScript.
* (This is a convenience method)
*
* @param statement
* Deprecated (https://issues.apache.org/jira/browse/CB-6851)
* Instead of executing snippets of JS, you should use the exec bridge
* to create a Java->JS communication channel.
* To do this:
* 1. Within plugin.xml (to have your JS run before deviceready):
* <js-module><runs/></js-module>
* 2. Within your .js (call exec on start-up):
* require('cordova/channel').onCordovaReady.subscribe(function() {
* require('cordova/exec')(win, null, 'Plugin', 'method', []);
* function win(message) {
* ... process message from java here ...
* }
* });
* 3. Within your .java:
* PluginResult dataResult = new PluginResult(PluginResult.Status.OK, CODE);
* dataResult.setKeepCallback(true);
* savedCallbackContext.sendPluginResult(dataResult);
*/
@Deprecated
public void sendJavascript(String statement) {
this.jsMessageQueue.addJavaScript(statement);
}