ionic 3+cordovaオーロラプッシュ記録

2919 ワード

わたしはシロ 会社のプロジェクトはプッシュ通知が必要なため  そこでオーロラプッシュを選択   以下は あるコードは切り取った他の人のものです 次のように記録されています.
まず行くhttps://www.jiguang.cn/アカウントの登録
アプリケーションの申請 あなたのプロジェクトアプリケーションのパッケージ名を記入します. あなたのプロジェクトのconfig.xmlでAPPKeyを取得しました. 覚えてろ!
そして公式cordovaプラグインをインストールします
cordova plugin add jpush-phonegap-plugin --variable APP_KEY=your_jpush_appkey

cnpm install ionic2-jpush --save
home.tsに

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';

import { Platform } from 'ionic-angular';
import { JPushService } from 'ionic2-jpush/dist'

@Component({
  selector: 'page-home',
  templateUrl: 'home.html',
  providers  : [JPushService]
})

export class HomePage {
    constructor(public navCtrl: NavController, private platform: Platform,private jPushPlugin: JPushService) {
    	let openNotification = this.jPushPlugin.openNotification()
         .subscribe( res => {
           console.log(res);
           console.log('        ')
         })
 
 
       let receiveNotification = this.jPushPlugin.receiveNotification()
         .subscribe( res => {
           console.log(res)
           console.log('    ')
         })
 
       let receiveMessage = this.jPushPlugin.receiveMessage()
         .subscribe( res => {
           console.log(res)
           console.log('       ')
         })
 
       let backgroundNotification = this.jPushPlugin.backgroundNotification()
         .subscribe( res => {
           console.log(res)
           console.log('      ')
         })
    }

       /**
    *     
    */
   init() {
    this.jPushPlugin.init()
    .then(res => alert(res))
    .catch(err => alert(err))
    }
 
    /**
    *   ID
    */
    getRegistrationID() {
     this.jPushPlugin.getRegistrationID()
     .then(res => alert(res))
     .catch(err => alert(err))
     }

}

home.html

  
    Home
  




  

ionic2-jpush-demo

ionic2-jpush-demo


API   っておきましょう
IDの に した 、または は のように されます.
1.まずアプリケーションパッケージがオーロラ サイトと しているかどうかを する
2.ローカルプロジェクトの の
 platforms/android/AndroidManifest.xml  および android.json
plugins/android.jsと fetch.json