ionic2/3 極光推送@ionic-native

@Ionic-Native-Cordova-Plugin

Github: https://github.com/kongdewen1994/ionic2-jpush-cordova-plugin

支持 iOS, Android 的 Cordova 極光推送插件( ionic2/3 @ionic-native??封裝)。

Install

  • 通過 Cordova Plugins 安裝,要求 Cordova CLI 5.0+:

    ionic cordova plugin add jpush-phonegap-plugin --variable APP_KEY=your_jpush_appkey
    
  • 或直接通過 url 安裝:

    ionic cordova plugin add https://github.com/jpush/jpush-phonegap-plugin.git --variable APP_KEY=your_jpush_appkey  
    

Usage

API

Usage

The dist directory will contain a sub directory @ionic-native with all the packages compiled in there. Copy the package(s) you created/modified to your app's node_modules under the @ionic-native directory. (e.g. cp -r dist/@ionic-native/plugin-name ../my-app/node_modules/@ionic-native/).

???? 將 dist/@ionic-native 的 jpush文件夾復(fù)制到 ionic2項目的 node_modules/@ionic-native/ 下

Add Plugins to Your App's Module

After installing a plugin’s package, add it to your app’s NgModule.


...

import { JPushPlugin } from '@ionic-native/jpush';

...

@NgModule({
  ...

  providers: [
    ...
    JPushPlugin
    ...
  ]
  ...
})
export class AppModule { }

import { JPushPlugin } from '@ionic-native/jpush';

constructor(public jpush: JPushPlugin) {
    this.init();
    //延遲執(zhí)行,等極光完全初始化
    setTimeout(()=>{
        this.setAlias( "Alias" );
    },300)
}

init(){
    //初始化極光
    this.jpush.init();
    
    //收到通知時會觸發(fā)該事件。
    document.addEventListener("jpush.receiveNotification", function (event) {
        alert( JSON.stringify( event ) );
    }, false);
    
}

//綁定別名
setAlias( Alias : string ){
    jpush.setAlias( Alias ).then((res)=>{
            alert( JSON.stringify(res) );
        }).catch((err)=>{
            alert( JSON.stringify(err) );
        });
}

............

...


Support

  • QQ 群:513752928
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容