Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cordova-plugin-push-baidu

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-push-baidu

Baidu push notification plugin for cordova

  • 5.3.1000
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

cordova-plugin-baidu-push

-- 2016.06.06 Updated iOS SDK 1.4.5, Android 5.0.0 -- 2015.06.17 IOS SDK -- 2015.06.15 Android SDK【L2-4.4.1】

Installation

$ ionic plugin add cordova-plugin-push-baidu

Usage

var api_key = 'SJI7BJ4hg8k5BUJ6LWVXit35' // your api key

document.addEventListener("deviceready", function () {

  window.baiduPush.onMessage(function (result) {
    console.log('onMessage success', result);
  }, function () {
    console.error('onMessage fail', error);
  })

  window.baiduPush.onNotificationClicked(function (result) {
    console.log('onNotificationClicked success', result);
  }, function (error) {
    console.error('onNotificationClicked fail', error);
  })

  window.baiduPush.onNotificationArrived(function (result) {
    console.log('onNotificationArrived success', resultj);
  }, function (error) {
    console.error('onNotificationArrived fail', error);
  })

  window.baiduPush.startWork(api_key, function (result) {
    console.log('startWork success', resultj);
  }, function (error) {
    console.error('startWork fail', error);
  })
}, false);

API

baiduPush.startWork

baiduPush.startWork(api_key, cb_success);
# api_key: Baidu cloud push api_key
# cb_success: callback method call succeeds, will not consider callback call fails, the return value is structured as follows:
  #json: {
    type: 'onbind', // method of the corresponding Android Service
    data: {
      appId: 'xxxxxxxx',
      userId: 'yyyyy',
      channelId: 'zzzzzz'
    }
  }

baiduPush.stopWork

baiduPush.startWork(cb_success);
# cb_success: callback method call succeeds, will not consider callback call fails, the return value is structured as follows:
  #json: {
    type: 'onunbind', // method of the corresponding Android Service
    errorCode: 'xxxxxx', // error code corresponding to Baidu's request
    data: {
      requestId: 'yyyyyy', // request ID corresponding to Baidu
    }
  }

baiduPush.resumeWork

baiduPush.resumeWork(cb_success);
# cb_success: callback method can call succeeds, the return value is structured as follows: Method with baiduPush.startWork

baiduPush.setTags

baiduPush.setTags(tags, cb_success);
# tags[]: tag name you want to set
# cb_success: callback method call succeeds, will not consider callback call fails, the return value is structured as follows:
  #json: {
    type: 'onsettags',
    errorCode: 'xxxxxxxx',
    data: {
      requestId: 'yyyyy',
      channelId: 'zzzzzz'
      sucessTags: ['aaa', 'bbb', 'ccc'], // set success tag list
      failTags: ['ddd', 'eee', 'fff'] // tag list settings failed
    }
  }

baiduPush.delTags

baiduPush.delTags(tags, cb_success);
# tags[]: tag name you want to remove
# cb_success: callback method call succeeds, will not consider callback call fails, the return value is structured as follows:
  #json: {
    type: 'ondeltags',
    errorCode: 'xxxxxxxx',
    data: {
      requestId: 'yyyyy',
      channelId: 'zzzzzz'
      sucessTags: ['aaa', 'bbb', 'ccc'], // set success tag list
      failTags: ['ddd', 'eee', 'fff'] // tag list settings failed
    }
  }

onMessage

baiduPush.onMessage(cb_success, failureCallback)

onNotificationClicked

baiduPush.onNotificationClicked(successCallback, failureCallback)
# successCallback: callback method call succeeds, will not consider callback call fails, the return value is structured as follows:
  #json: {
	  "data": {
	    "title": "foo",
	    "description": "bar",
	    "customContentString": "{\"Additional Field Key\":\"Additional Field Value\"}"
	  },
	  "type": "onNotificationClicked"
	}

onNotificationArrived

baiduPush.onNotificationArrived(successCallback, failureCallback)
# successCallback: callback method call succeeds, will not consider callback call fails, the return value is structured as follows:
  #json: {
	  "data": {
	    "title": "foo",
	    "description": "bar",
	    "customContentString": "{\"Additional Field Key\":\"Additional Field Value\"}"
	  },
	  "type": "onNotificationArrived"
	}

Other instructions:

  1. Json Parameters on the type of callback method can return the following values ​​that correspond Android's Service of Baidu cloud push callback method onbind, onunbind, onsettags, ondeltags, onlisttags, onmessage, onnotificationclicked, onnotificationarrived

  2. Since Baidu applications different android and ios, APP client can use the following method to determined it:

ionic.Platform.isIOS()
ionic.Platform.isAndroid()

Keywords

FAQs

Package last updated on 07 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc