公司项目须要增长推送功能,网上有不少文章,参考官方给的博客本身整理了一份
参考文献:http://www.cnblogs.com/linsu/...html
第一步去官网注册开发者帐号,生成本身的项目
https://www.jiguang.cn/java
注:应用包名要与项目config.xml widget id 保持一致android
第二步添加jpush插件
git clone https://github.com/jpush/jpus...git
进入项目目录添加jpush
首先要把widget id信息引用到jpush-phonegap-plugin/src/android/JPushPlugin.javagithub
import io.ionic.starter;
cordova plugin add $dir/jpush-phonegap-plugin --variable APP_KEY=you key
注:$dir插件位置 youkey是在极光推送下生成的app_key 要用管理员权限npm
第三步安装 jpush device
npm install --save @jiguang-ionic/jpush
npm install --save @ionic-native/deviceapp
而后在 app.module.ts 中增长:ionic
import { Device } from '@ionic-native/device'; import { JPush } from '@jiguang-ionic/jpush'; providers: [ ... Device, JPush, ... ]
在app.component.ts下增长ide
import { JPush } from '@jiguang-ionic/jpush'; constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, jpush: JPush) { platform.ready().then(() => { // Okay, so the platform is ready and our plugins are available. // Here you can do any higher level native things you might need. statusBar.styleDefault(); splashScreen.hide(); jpush.init(); jpush.setDebugMode(true); }); }
第四步生成androd apk
ionic build androidui