2.0.0 • Published 8 years ago

ionic-platform-push v2.0.0

Weekly downloads
6
License
-
Repository
github
Last release
8 years ago

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

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
  • Getting tokens for user_ids
2.0.0

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago