Correspondent
Cordova Web View sendjavascript is deprecated and it doesn't work for me. My java code:
public static void sendJavascript(JSONObject _json) {
String _d = "javascript:" + gECB + "(" + _json.toString() + ")";
Log.v(TAG, "sendJavascript: " + _d);
Log.i(TAG,_d);
if (gECB != null && gWebView != null) {
gWebView.sendJavascript(_d);//deprecated method
}
}
My java script code:
document.addEventListener("deviceready", function(){
window.plugins.pushNotification.register(successHandler, errorHandler, {
ecb : 'onNotificationGCM',
senderID : 'xxxxxxxxxxxxx'
});
// Method to handle device registration for Android.
var onNotificationGCM = function(e) {
if('registered' === e.event) {
// Successfully registered device.
alert(e.regid);
}
else if('error' === e.event) {
// Failed to register device.
alert(e.msg);
}
else if('message' === e.event) {
//mesage recived
alert(e.payload.message);
}
};
// result contains any message sent from the plugin call
function successHandler (result) {
alert('gcm result = ' + result);
}
// result contains any error description text returned from the plugin call
function errorHandler (error) {
alert('error = ' + error);
}
});
Deprecated details: https://apache.googlesource.com/cordova-android/+/3.6.1/framework/src/org/apache/cordova/CordovaWebView.java
Please help me?
+3
source to share