ionic3 極光推送實例

公司項目須要增長推送功能,網上有不少文章,參考官方給的博客本身整理了一份
參考文獻:http://www.cnblogs.com/linsu/...html

第一步去官網註冊開發者帳號,生成本身的項目
https://www.jiguang.cn/java

clipboard.png
clipboard.png

注:應用包名要與項目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

clipboard.png

第三步安裝 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

相關文章
相關標籤/搜索