Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

ionic-api

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ionic-api

API Client for Ionic Push Service

latest
Source
npmnpm
Version
0.9.1
Version published
Maintainers
1
Created
Source

IonicAPI Client

=================

Ionic API Client NPM Module. It uses Promises on requests. Compatible with Ionic v2 https://docs.ionic.io/api/endpoints/push.html

Install

npm install ionic-api

Init


var config = {
  // https://apps.ionic.io/app/{APP_ID}/config/credentials
  apiToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjMjM1YWJmMy0zZWUyLTRlNzMtYWRjYS00N2VlNjAxZWU0MWYifQ.h_uKtDKhZiURSjCzi4GTDwjbGMuRsXPA3q_O86VY-vA'
}
var ionic = require('./ionic-api').init(config);

Sections

Device tokens

ionic.tokens
  • list(options)
  • create(token_id [, user_id])
  • retrieve(token_id)
  • update(token_id[, valid])
  • delete(token_id)
  • listAssociatedUsers(token_id)
  • associateUser(token_id)
  • dissociateUser(token_id, user_id)

Messages

ionic.messages
  • retrieve(message_id)
  • delete(message_id)

Notifications

ionic.notifications
  • list(options)
  • create(notification, target, profile)
  • retrieve(notification_id [, fields=[]])
  • replace(notification_id, body)
  • delete(notification_id)
  • listMessages(notification_id, options)

Usage

// Getting tokens list
ionic.tokens.list().then((res) => {
  // res: {meta:{}, data:{}}

  // Filter out invalidated tokens
  var tokens = res.data
          .filter(a => a.invalidated === null)
          .map(a => a.token);

  // Creating notifications...
  var notification = {
    title: 'Testing title',
    message: 'Message text...',
  };

  //https://docs.ionic.io/api/endpoints/push.html#post-notifications
  var target = {
    tokens: tokens,
    // user_ids: ['something@mail.com']
  };
  // https://apps.ionic.io/app/{APP_ID}/config/credentials
  var profile = 'IONIC_PROFILE';

  return ionic.notifications.create(notification, target, profile).then(res => {
    // Successful response
    console.dir(res.data);
  });
  //console.dir(d);
}).catch(err => {
  console.dir(err);
});

Keywords

ionic

FAQs

Package last updated on 21 May 2017

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