安装插件
cordova plugin add jmessage-phonegap-plugin --variable APP_KEY=your_app_key
安装ionic2、3调用
npm install jmessage-chenyu --save
For the full Ionic Native documentation, please visit https://ionicframework.com/docs/native/.
import {JmessageChenyu} from "jmessage-chenyu";
import { Platform } from 'ionic-angular';
import { NgZone } from '@angular/core';
@Component({ ... })
export class MyComponent {
constructor(private jMessageChenyu: JmessageChenyu, private platform: Platform) {
platform.ready().then(() => {
this.jMessageChenyu.init({ isOpenMessageRoaming: true })
let obj ={username: id, password: '123456'}
this.jMessageChenyu.register(obj)
.then(() => {
this.toast("注册成功,请登录!")
})
.catch((error) => {
this.toast("注册失败" + JSON.stringify(error))
});
this.jMessageChenyu.login(obj).then(
)
this.jMessageChenyu.logout().then(
)
this.jMessageChenyu.getMyInfo().then()
});
}
}