npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-push-baidu-2024

v1.0.22

Published

Baidu push notification plugin for cordova

Downloads

181

Readme

cordova-plugin-baidu-push

-- 2017.02.17 Updated Android SDK 5.6.0.30 -- 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();