Ionic Framework 4 is almost here. Preview the beta docs and try it out now! Try Ionic 4 Beta

Baidu Push

Improve this doc

This plugin faciliates the use of Baidu Push notifications.

Repo: https://github.com/Ti-webdev/cordova-plugin-push-baidu.git

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-plugin-push-baidu
    $ npm install --save @ionic-native/baidu-push
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { BaiduPush } from '@ionic-native/baidu-push';


constructor(private baiduPush: BaiduPush) { }

...

this.baiduPush.startWork('xxxxxx')
  .then((res: any) => console.log(res))
  .catch((error: any) => console.error(error));

Instance Members

startWork(apiKey)

This method registers the device to Baidu Cloud Push services.

Param Type Details
apiKey string

Baidu Cloud Push API key.

Returns: Promise<BaiduResponse<RegistrationData>> Returns a Promise that resolves with a BaiduResponse.

stopWork()

This method unregisters the device to Baidu Cloud Push services.

Returns: Promise<BaiduResponse<UnregistrationData>> Returns a Promise that resolves with a BaiduResponse.

resumeWork()

This method re-binds the device to Baidu Cloud Push services.

Returns: Promise<BaiduResponse<RegistrationData>> Returns a Promise that resolves with a BaiduResponse.

setTags(tags)

This sets tags in the Baidu Cloud Push services.

Param Type Details
tags any

tags The tags to set.

Returns: Promise<BaiduResponse<TagData>> Returns a Promise that resolves with a BaiduResponse.

delTags(tags)

This sets tags in the Baidu Cloud Push services.

Param Type Details
tags any

tags The tags to set.

Returns: Promise<BaiduResponse<TagData>> Returns a Promise that resolves with a BaiduResponse.

onMessage()

This method is called when a notification is recieved on the foreground.

Returns: Promise<BaiduResponse<NotificationData>> Returns a Promise that resolves with a BaiduResponse.

onNotificationClicked()

This method is called when the user taps a notification.

Returns: Promise<BaiduResponse<NotificationData>> Returns a Promise that resolves with a BaiduResponse.

onNotificationArrived()

This method is called when a notification is recieved.

Returns: Promise<BaiduResponse<NotificationData>> Returns a Promise that resolves with a BaiduResponse.

BaiduResponse

Param Type Details
type string

The corresponding Baidu SDK method called.

errorCode string

The error code corresponding to Baidu's request.

(optional)
data T

Registration data revelvant to subsequent actions.

RegistrationData

Param Type Details
appId string

The ID registered to Baidu for the app.

userId string

The ID registered to Baidu for the device.

channelId string

The channel ID registered to Baidu for the app.

UnregistrationData

Param Type Details
requestId string

The ID corresponding to the Baidu request.

TagData

Param Type Details
requestId string

The ID corresponding to the Baidu request.

channelId string

The channel ID registered to Baidu for the app.

sucessTags string[]

The list of successfully set/deleted tags.

failTags string[]

The list of unsuccessfully set/deleted tags.

NotificationData

Param Type Details
title string

The title of the notification.

description string

The description of the notification.

customContentString string

Custom content for the notification.

(optional)

API

Native

General