How can I call a simple event or execute a JavaScript function in native Android code with Cordova?
I tried
public void notificationRecieved(String heading,String news){
try{
if(webview!=null){
Log.i("PUSHPARSE","in Notification Received Event");
//webview.loadUrl("javascript:alert('URLcall')");
webview.sendJavascript("alert('CAlling from Java')");
}
}catch(Exception e1){
Log.e("PUSHPARSE",e1.getMessage(),e1);
}
}
I am not able to get any notification or alert.
Update
Logcat shows I/PUSHPARSE( 2039): in Notification Received Event
Tried doing webview.loadUrl("http://www.google.com");
the logs show
>>> loadUrl(http://www.google.com)
W/CordovaWebView( 2039): CordovaWebView.init() was not called. This will soon be required.
D/CordovaWebView( 2039): CordovaWebView is running on device made by: unknown
I guess alert is not working in webview try document.write or console.log for see
Thanks
也许您可以使用pushPlugin https://github.com/phonegap-build/PushPlugin并使用方法函数onNotification(e)?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.