首先感谢@BenBBer 提供的 cordova-plugin-leanpush
安装plugin
cordova plugin add cordova-plugin-leanpush --variable LEAN_APP_ID=<YOUR_LEANCOULD_APP_ID> --variable LEAN_APP_KEY=<YOUR_LEANCOULD_APP_KEY>
添加gulp任务与依赖
gulp.task('lpush-install', function(done){ require('./plugins/cordova-plugin-leanpush/lpush-installer.js')(__dirname, done); });
npm install –save-dev xml2js thunks && npm install
最后运行 gulp lpush-install
安装步骤就完成了。
客户端还需要在deviceReady的时候使用 window.LeanPush.init()进行初始化。
如果出现打包的问题,请使用以下方法解决。
在build.gradle的android tag中加入
packagingOptions { exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' }