cordova-plugin-local-notifications本地通知推送在cordova 5.0.0以上版本编译报错解决办法

来源:互联网 发布:永安市招聘淘宝运营 编辑:程序博客网 时间:2024/06/05 03:03

添加本地推送插件cordova-plugin-local-notifications 0.8.1,在cordova 5.0.0以上版本编译报错

LocalNotification.java:495: error: cannot find symbolwebView.evaluateJavascript(js, null);^symbol: method evaluateJavascript(String,)location: variable webView of type CordovaWebView/ug/ug-app/platforms/android/src/de/appplant/cordova/plugin/localnotification/LocalNotification.java:492: error: cannot find symbolwebView.post(new Runnable(){^symbol: method post()location: variable webView of type CordovaWebViewNote: Some input files use or override a deprecated API.Note: Recompile with -Xlint:deprecation for details.2 errorsFAILEDFAILURE: Build failed with an exception.

修改cordova-plugin-local-notifications中源代码LocalNotification.java:492

替换为
webView.getView().post(new Runnable(){  public void run(){if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {  webView.sendJavascript(js);} else {  webView.loadUrl("javascript:" + js);}  }});

同时在platforms\android\src\de\appplant\cordova\plugin\localnotification.java 进行修改替换,运行cordova build android顺利通过。
原因是cordova 5.0.0以上版本对evaluateJavascript不再支持,用sendJavascript进行替换。
                                             
0 0
原创粉丝点击