ionic3 jpush android,ionic2/3 极光推送@ionic-native

@Ionic-Native-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文件夹复制到 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();    //延迟执行,等极光完全初始化

setTimeout(()=>{        this.setAlias( "Alias" );

},300)

}

init(){    //初始化极光

this.jpush.init();

//收到通知时会触发该事件。

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) );

});

}

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

...

作者:DevonKong

链接:https://www.jianshu.com/p/24f4fc37da8e

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值