Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cordova-plugin-getuisdk): Add GeTuiSdkPlugin plugin #3212

Merged
merged 1 commit into from Oct 30, 2019

Conversation

daduryi
Copy link
Contributor

@daduryi daduryi commented Oct 28, 2019

No description provided.

@daduryi
Copy link
Contributor Author

daduryi commented Oct 28, 2019

install plugin

个推官网
cordova-plugin-getuisdk

cordova plugin add cordova-plugin-getuisdk --variable PUSH_APPID=你的appid --variable PUSH_APPKEY=你的appkey --variable PUSH_APPSECRET=你的appsecret

used CordovaAndroid@7.0+

<edit-config file="app/src/main/AndroidManifest.xml" target="/manifest/application" mode="merge"> 

Usage

app.module.ts

import { GeTuiSdkPlugin } from '@ionic-native/ge-tui-sdk-plugin/ngx';

@NgModule({
...
providers: [..., GeTuiSdkPlugin],
...
})
export class AppModule {}

app.component.ts

import { GeTuiSdkPlugin } from '@ionic-native/ge-tui-sdk-plugin/ngx';

export class AppComponent implements OnInit {
  constructor(
    ...,
    private geTuiSdkPlugin: GeTuiSdkPlugin,
   ) {
    this.initializeApp();
  }

  initializeApp() {
    this.platform.ready().then(() => {
      ...,
      this.geTuiSdkPlugin.callback_init(this.getTuiCallBack);
      this.geTuiSdkPlugin.initialize();
    });
  }

  getTuiCallBack(type, data) {
    if (type === 'cid') {
      //TODO data = clientid
    } else if (type == 'pid') {
      //TODO data = 进程pid
    } else if (type == 'payload') {
      //TODO data=透传数据
    } else if (type == 'online') {
      if (data == 'true') {
        //TODO 已上线
      } else {
        //TODO 已离线
      }
    } else if (type === 'onNotificationArrived') {
      console.log('onNotificationArrived' + data) //通知到达回调
      alert('onNotificationArrived\n' + data) //通知到达回调
    } else if (type === 'onNotificationClicked') {
      console.log('onNotificationClicked' + data) //点击通知事件回调
      alert('onNotificationClicked\n' + data) //点击通知事件回调
    }
  }
}

@danielsogl danielsogl self-assigned this Oct 30, 2019
@danielsogl danielsogl added the target: minor This PR is targeted for the next minor release label Oct 30, 2019
@danielsogl danielsogl merged commit f81e181 into danielsogl:master Oct 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants