Skip to content

Installation Guide

huangminlinux edited this page Feb 26, 2019 · 6 revisions

Versions

支持系统:

  • Android 2.3 (API 9) 及以上;
  • iOS 7 及以上。

需要 Cordova 版本 >= 3.0。

Installation

在项目目录下执行:

$ cordova plugin add jmessage-phonegap-plugin --variable APP_KEY=your_app_key

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

或下载到本地执行:

$ cordova plugin add <plugin_local_path> --variable APP_KEY=your_app_key

注:APP_KEY 是在极光官网注册并创建应用得到的,极光控制台使用指南可以看这里

如果项目所基于的 cordova-android 版本低于 6.3.0,还需要安装 cordova-plugin-compat 插件以支持 Android 6.0 及以上在运行时请求权限。

Ionic

如果使用了 Ionic,可以再安装 @jiguang-ionic/jpush 包,适配 ionic-native:

npm install --save @jiguang-ionic/jmessage

# npm install --save @jiguang-ionic/jmessage@3.0.0+     for ionic4

然后在 app.module.ts 中增加:


import { JMessagePlugin } from '@jiguang-ionic/jmessage';  // @jiguang-ionic/jmessage@2.0.0+

import { JMessagePlugin } from '@jiguang-ionic/jmessage/ngx';  // @jiguang-ionic/jmessage@3.0.0+
...
  providers: [
    ...
    JMessagePlugin,
    ...
  ]

example:

example.componnet.ts

import { Component } from '@angular/core';
import { Platform, Alert } from 'ionic-angular';
import { JMessagePlugin } from '@ionic-native/jmessage';


export class MyApp {
  rootPage:any = HomePage;

  constructor(private jmessage: JMessagePlugin,platform: Platform) {
      constructor(private jmessage: JMessagePlugin,platform: Platform) {
        this.jmessage.init({ isOpenMessageRoaming: true });
      }
  }
}
Clone this wiki locally