Giter Club home page Giter Club logo

ionic-push-node's Introduction

Ionic Platform Push (node)

A node.js client for creating and sending Ionic Push notifications

If you haven't, read the docs!

Installation

npm install --save ionic-platform-push

Basic Usage

Contents

Initialize the Service

var Push = require('ionic-platform-push');

var sender = Push({
  "api_key": "yourKey"
});

Send a push:

var notification = {
  "tokens": ["someToken"],
  "profile": "someProfile"
  "notification": {
    "title": "Hi",
    "message": "Hello world!",
    "android": {
      "title": "Hey",
      "message": "Hello Android!"
    },
    "ios": {
      "title": "Howdy",
      "message": "Hello iOS!"
    }
  }
}

sender.send(notification);

Check the status of a push:

var uuid = "some-notification-uuid";

sender.status(uuid).then(function(status){
  console.log(status);
});

List notifications:

var page = 1;
sender.notifications(page).then(function(notifications) {
  console.log(notifications);
});

Note: The page argument is optional, and will be defaulted to 1.

List tokens:

Recent tokens:

sender.tokens().then(function(tokens) {
  console.log(tokens);
});

Tokens for a given user_id:

var uuid = 'some-ionic-user-uuid';
sender.tokens(uuid).then(function(tokens) {
  console.log(tokens);
});

Promises

Everything returns promises, which work like so:

sender.send(notification).then(function(success) {
  console.log(success);
}, function(errors) {
  console.warn(errors);
});

Check out the examples folder to see what those resolves and rejects will give you.

Set a Default Profile

To specify a profile to use by default, simply update your config object to include a profile field like so:

var config = {
  "api_key": "yourKey",
  "profile": "yourProfile"
}

This will default notifications you send to the specified profile of none is present.

Todos

  • Write some tests
  • Adding tokens
  • Token invalidation

ionic-push-node's People

Contributors

fuiste avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

chaabni

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.