ionic3 集成极光推送

1、在极光后台添加app得到appKey,包名需要和ionic包名一致。ionic 工程中加入jpush插件
通过 Cordova Plugins 安装,要求 Cordova CLI 5.0+:

cordova plugin add jpush-phonegap-plugin --variable APP_KEY=appKey

或直接通过 url 安装:

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

2、安装 @jiguang-ionic/jpush 包

npm install --save @jiguang-ionic/jpush@1.0.2

**# npm install --save @jiguang-ionic/jpush@2.0.0 for ionic4+**

3、安装 @jiguang-ionic/jpush 以后,在 app.module.ts 文件中,导入,然后添加到 服务(providers)中。

import { JPush } from '@jiguang-ionic/jpush';
...
  providers: [
    ...
    JPush,
    ...
  ]

4、在app.component.ts 初始化

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

官网地址:https://github.com/jpush/jpush-phonegap-plugin

可能出现的问题
[JCoreGlobal] JCore .so file do not match JCore .jar file in the project, Failed to init JCore

找不到so文件,解决方法为:在build.gradle 中 设置jni路径

sourceSets {
           main {
            jniLibs.srcDirs = ['jniLibs']
        }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值