Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including leancloudjs with all npm packages installed. Try it out:

var leancloudjs = require("leancloudjs")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

leancloudjs v1.0.1

leacloud api sdk

leancloudjs

Leancloud JavaScript SDK. Build status

Install

npm install leancloudjs

Methods

Leancloud

Initialize a instance of Leancloud.

  • options {Object}:
    • appId {String}: leancloud's application id, required
    • appKey {String}: leancloud's application key, required
    • timeout {Number}: Receive response timeout, default is 10000ms
    • hostname {String}: leancloud hostname, default is leancloud.cn
    • version {String}: api version, default is 1.1

Usage

const Leancloud = require('leancloudjs');
const cli = new Leancloud({
  appId: 'application id',
  appKey: 'application key'
});

push

Call leancloud'push notification api.

  • data {Object}:
    • alert {String}: display message
    • badge {Number}: the number of new notifications
    • sound {String}: alert sound
  • channel {String}: who receive notification
  • deviceType {String}: ios or android
  • conditions {Object}:
    • valid {Boolean}: client is valid or not, default is true

Usage

cli.push({alert: 'test'}, 'channe', 'ios').then((rst) => {
  console.log(rst);
});

TODOs

  • Support more leancloud apis.
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free