-
Notifications
You must be signed in to change notification settings - Fork 28
Installation Guide
huangminlinux edited this page Feb 26, 2019
·
6 revisions
支持系统:
- Android 2.3 (API 9) 及以上;
- iOS 7 及以上。
需要 Cordova 版本 >= 3.0。
在项目目录下执行:
$ 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
如果项目所基于的 cordova-android 版本低于 6.3.0,还需要安装 cordova-plugin-compat 插件以支持 Android 6.0 及以上在运行时请求权限。
如果使用了 Ionic,可以再安装 @jiguang-ionic/jpush 包,适配 ionic-native:
npm install --save @jiguang-ionic/jmessage
# npm install --save @jiguang-ionic/[email protected]+ for ionic4
然后在 app.module.ts 中增加:
import { JMessagePlugin } from '@jiguang-ionic/jmessage'; // @jiguang-ionic/[email protected]+
import { JMessagePlugin } from '@jiguang-ionic/jmessage/ngx'; // @jiguang-ionic/[email protected]+
...
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 });
}
}
}