RocketChat/push

Name: push

Owner: Rocket.Chat

Description: Push notifications for cordova (ios, android) browser (Chrome, Safari, Firefox)

Forked from: raix/push

Created: 2016-06-03 20:02:05.0

Updated: 2018-03-03 21:13:12.0

Pushed: 2017-11-24 17:37:10.0

Homepage: https://atmospherejs.com/raix/push

Size: 288

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Gi-SoftWare

raix:push Push notifications

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

Status:

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

Read the raix:push Newbie Manual by @harryward

Or check out the DEMO by @elvismercado

Example code for sound (todo: add in docs)

Note: Version 3 uses the cordova npm plugin phonegap-plugin-push

Config

Use the Push.Configure function on client and server.

On the client

.Configure({
droid: {
senderID: 12341234,
alert: true,
badge: true,
sound: true,
vibrate: true,
clearNotifications: true
// icon: '',
// iconColor: ''

s: {
alert: true,
badge: true,
sound: true


Additionally you have to touch mobile-config.js

configurePlugin('phonegap-plugin-push', {
NDER_ID: 12341234

This is due to changes in the cordova plugin it self

Server:

.Configure({
n: {
certData: Assets.getText('apnDevCert.pem'),
keyData: Assets.getText('apnDevKey.pem'),
passphrase: 'xxxxxxxxx',
production: true,
//gateway: 'gateway.push.apple.com',

m: {
apiKey: 'xxxxxxx',

 production: true,
 'sound' true,
 'badge' true,
 'alert' true,
 'vibrate' true,
 'sendInterval': 15000, Configurable interval between sending
 'sendBatchSize': 1, Configurable number of notifications to send per batch
 'keepNotifications': false,


Note: config.push.json is deprecating

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

Push.send({
    from: 'push',
    title: 'Hello',
    text: 'world',
    badge: 1, //optional, use it to set badge count of the receiver when the app is in background.
    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
    // delayUntil: Date
});

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
Push.enabled(); // Return true or false
Push.enabled(false); // Will disable notifications
Push.enabled(true); // Will enable notifications (requires a token...)
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:

Returns:

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


sult: '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:

More Info

For more internal or advanced features read ADVANCED.md

Kind regards

Morten (aka RaiX)


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.