Giter Club home page Giter Club logo

push's Introduction

Gi-SoftWare

raix:push Push notifications =========

Push notifications for cordova (ios, android) browser (Chrome, Safari, Firefox) - One unified api on client and server.

Status:

  • APN iOS
  • GCM Android
  • APN Safari web push (partially implemented)
  • GCM Chrome OS (partially implemented)
  • Firefox OS (partially implemented)
  • BPS Blackberry 10
  • MPNS Windows phone 8
  • MPNS Windows 8
  • ADM Amazon Fire OS
  • Meteor in app notifications

Getting started

Depending on the platforms you want to work with you will need some credentials or certificates.

Have a look at the Basic example

Or check out the DEMO by @elvismercado

Config

Add a config.push.json file in your project and configure credentials / keys / certificates:

{
  "apn": {
    "passphrase": "xxxxxxxxx",  
    "key": "apnProdKey.pem",
    "cert": "apnProdCert.pem"
  },
  "apn-dev": {
    "passphrase": "xxxxxxxxx",
    "key": "apnDevKey.pem",
    "cert": "apnDevCert.pem"
  },  
  "gcm": {
    "apiKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "projectNumber": xxxxxxxxxxxx
  },
  "production": true,
  // "badge": true,
  // "sound": true,
  // "alert": true,
  // "vibrate": true
}

Note: This file should be pure json, comments are not supported

Common api

    // Push.debug = true; // Add verbosity

    Push.send({
        from: 'push',
        title: 'Hello',
        text: 'world',
        query: {
            // Ex. send to a specific user if using accounts:
            userId: 'xxxxxxxxx'
        } // Query the appCollection
        // token: appId or token eg. "{ apn: token }"
        // tokens: array of appId's or tokens
        // payload: user data
    });

When in secure mode the client send features require adding allow/deny rules in order to allow the user to send push messages to other users directly from the client - Read more below

Client api

    Push.id(); // Unified application id - not a token
    Push.setBadge(count); // ios specific - ignored everywhere else

Security allow/deny send

This package allows you to send notifications from the server and client. To restrict the client or allowing the client to send use allow or deny rules.

When a client calls send on Push, the Push's allow and deny callbacks are called on the server to determine if the send should be allowed. If at least one allow callback allows the send, and no deny callbacks deny the send, then the send is allowed to proceed.

    Push.allow({
        send: function(userId, notification) {
            return true; // Allow all users to send
        }
    });

    // Or...
    Push.deny({
        send: function(userId, notification) {
            return false; // Allow all users to send
        }
    });

Meteor Methods

raix:push-update

Stores a token associated with an application and optionally, a userId.

Parameters:

options - An object containing the necessary data to store a token. Fields:

  • id - String (optional) - a record id for the Application/Token document to update. If this does not exist, will return 404.
  • token - Object - { apn: 'TOKEN' } or { gcm: 'TOKEN' }
  • appName - String - the name of the application to associate the token with
  • userId - String (optional) - the user id so associate with the token and application. If none is included no user will be associated. Use raix:push-setuser to later associate a userId with a token.

Returns:

recordId - The id of the stored document associating appName, token, and optionally user in an object of the form:

{
  result: 'recordId'
}

raix:push-setuser

Associates the current users ID with an Application/Token record based on the given id.

Parameters:

id - String - The ID of the Application/Token record

raix:push-metadata

Adds metadata to a particular Application/Token record.

Parameters

data - Object containing the following fields:

  • id - String - the ID of the Application/Token record to update
  • metadata - Object - The metadata object to add to the Application/Token document

More Info

For more internal or advanced features read ADVANCED.md

Kind regards

Morten (aka RaiX)

push's People

Contributors

dennisharrison avatar funkyeah avatar wrannaman avatar

Watchers

 avatar  avatar

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.