• Stars
    star
    515
  • Rank 85,879 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 10 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

DEPRECATED: This package is no longer maintained

Gi-SoftWare

raix:push Push notifications

Build Status semantic-release

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

Status:

  • APN iOS
  • GCM/FCM 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

Contributing

We are using semantic-release following the AngularJS Commit Message Conventions - Following this pattern will result in better versioning, better changelog and shorter release cycle.

Updates For Android 8.0

Meteor must be version 1.6.1

Cordova Android must be version 6.3.0 Cordova IOS must be version 4.5.0

Meteor release 1.6.1 https://docs.meteor.com/changelog.html#changes-10 "The cordova-lib package has been updated to version 7.1.0, cordova-android has been updated to version 6.4.0 (plus one additional commit), and cordova-ios has been updated to version 4.5.4"

To verify the correct installation ADD [email protected] to your cordova plugins file.

After your app builds, Make the following changes to your build.gradle file. The simpliest solution to modify this file is in android studio.

The correct gradle file to modify has this line at the begining of the file:

apply plugin: 'com.android.application'

Add this two your dependencies:

classpath 'com.google.gms:google-services:4.1.0' // I added both of these
classpath 'com.google.firebase:firebase-core:11.0.1' // I added both of these

At the end of your build.gradle file add:

apply plugin: 'com.google.gms.google-services'

In case your run into errors with conflicting google libraries add:

configurations.all {
  resolutionStrategy {
    force 'com.android.support:support-v4:27.1.0'
  }
}

configurations {
  all*.exclude group: 'com.android.support', module: 'support-v13'
}

Other errors refer to:

https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/INSTALLATION.md#co-existing-with-plugins-that-use-firebase

Changes for the API: On the client make sure you add a android channel:

PushNotification.createChannel(
    () => {
        console.log('createChannel');
    },
    () => {
        console.log('error');
    },
    {
       id: Meteor.userId(), //Use any Id you prefer, but the same Id for this channel must be sent from the server, 
       description: 'Android Channel', //And any description your prefer
       importance: 3,
       vibration: true
      }
);

Server changes: Add the android_channel_id so the Push message like below:

Push.send({
	  from: 'test',
	  title: 'test',
	   text: 'hello',
          android_channel_id:this.userId,		//The android channel should match the id on the client
          query: {
              userId: this.userId
          }, 
          gcm: {
            style: 'inbox',
            summaryText: 'There are %n% notifications'
          },          
});  

Install

  $ meteor add raix:push
  $ meteor add cordova:[email protected]
  $ meteor add cordova:[email protected]
  # Note: you probably want to adjust the version numbers to the latest versions of the packages

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

Theres a good walkthrough by Arthur Carabott

Read the raix:push Newbie Manual by @harryward

Or check out the DEMO by @elvismercado (This example uses the deprecated config.push.json)

Example code for sound (todo: add in docs)

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

Note: Some of the documentation is outdated, please file an issue or create a pull request - same if you find a bug or want to add tests

Development

Watch the project progress for status or join development

Config

Use the Push.Configure function on client and server.

Client

For example in Meteor.startup() block of main.js

Push.Configure({
  android: {
    senderID: 12341234,
    alert: true,
    badge: true,
    sound: true,
    vibrate: true,
    clearNotifications: true
    // icon: '',
    // iconColor: ''
  },
  ios: {
    alert: true,
    badge: true,
    sound: true
  }
});

Additionally you have to touch mobile-config.js

App.configurePlugin('phonegap-plugin-push', {
  SENDER_ID: 12341234
});

This is due to changes in the cordova plugin itself

Server

For example in Meteor.startup() block of main.js

Push.Configure({
  apn: {
    certData: Assets.getText('apnDevCert.pem'),
    keyData: Assets.getText('apnDevKey.pem'),
    passphrase: 'xxxxxxxxx',
    production: true,
    //gateway: 'gateway.push.apple.com',
  },
  gcm: {
    apiKey: 'xxxxxxx',  // GCM/FCM server key
  }
  // 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:

  • 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

For maintainers

We have a slack channel to keep communication tight between contributors - it's on https://meteoropensourcecomm.slack.com in channel #raixpush

Kind regards

Morten (aka RaiX)

More Repositories

1

meteor-autoform

AutoForm is a Meteor package that adds UI components and helpers to easily create basic forms with automatic insert and update events, and automatic reactive validation.
JavaScript
1,439
star
2

Meteor-CollectionFS

Reactive file manager for Meteor
JavaScript
1,051
star
3

meteor-collection2

A Meteor package that extends Mongo.Collection to provide support for specifying a schema and then validating against that schema when inserting and updating.
JavaScript
1,024
star
4

meteor-roles

Authorization package for Meteor, compatible with built-in accounts packages
JavaScript
920
star
5

meteor-simple-schema

Meteor integration package for simpl-schema
JavaScript
920
star
6

meteor-collection-hooks

Meteor Collection Hooks
JavaScript
657
star
7

ground-db

GroundDB is a thin layer providing Meteor offline database and methods
JavaScript
569
star
8

meteor-user-status

Track user connection state and inactivity in Meteor.
JavaScript
557
star
9

meteor-publish-composite

Meteor.publishComposite provides a flexible way to publish a set of related documents from various collections using a reactive join
JavaScript
553
star
10

meteor-tabular

Reactive datatables for large or small datasets
JavaScript
363
star
11

meteor-autocomplete

Client/server autocompletion designed for Meteor's collections and reactivity.
CoffeeScript
350
star
12

meteor-scss

Node-sass wrapped to work with meteor.
JavaScript
311
star
13

meteor-partitioner

Transparently divide a single meteor app into several different instances shared between different groups of users.
CoffeeScript
152
star
14

meteor-timesync

NTP-style time synchronization between server and client, and facilities to use server time reactively in Meteor applications.
JavaScript
118
star
15

meteor-link-accounts

Meteor link account package. based on this PR https://github.com/meteor/meteor/pull/1133
JavaScript
116
star
16

mongo-collection-instances

πŸ—‚ Meteor package allowing Mongo Collection instance lookup by collection name
JavaScript
73
star
17

Meteor-EventEmitter

Client and server event emitter
JavaScript
72
star
18

meteor-postcss

PostCSS for Meteor
JavaScript
68
star
19

meteor-mocha

A Mocha test driver package for Meteor 1.3+. This package reports server AND client test results in the server console and can be used for running tests on a CI server or locally.
JavaScript
67
star
20

meteor-elastic-apm

Meteor Elastic APM integration
JavaScript
57
star
21

organization

Discussions on organization of the organization 🎩
41
star
22

meteor-schema-index

Control some MongoDB indexing with schema options
JavaScript
38
star
23

meteor-publication-collector

Test a Meteor publication by collecting its output.
JavaScript
33
star
24

meteor-collection-extensions

Safely and easily extend the (Meteor/Mongo).Collection constructor with custom functionality.
JavaScript
31
star
25

stratosphere

Meteor private package server
JavaScript
28
star
26

meteor-method-hooks

JavaScript
26
star
27

meteor-autoform-select2

Custom select2 input type for AutoForm
JavaScript
25
star
28

meteor-autoform-bs-datepicker

Custom "bootstrap-datepicker" input type for AutoForm
JavaScript
25
star
29

react-router-ssr

Simple isomorphic React SSR for Meteor with subscribed data re-hydration
JavaScript
24
star
30

denormalize

Simple denormalization for Meteor
JavaScript
20
star
31

meteor-autoform-bs-datetimepicker

Custom bootstrap-datetimepicker input type with timezone support for AutoForm
JavaScript
17
star
32

meteor-packages

Client for Meteor Package Server API
JavaScript
14
star
33

Packosphere

A Meteor package explorer for you, and if you are so inclined to help build it, by you.
TypeScript
13
star
34

meteor-schema-deny

Deny inserting or updating certain properties through schema options
JavaScript
12
star
35

check-npm-versions

Enforces "peer" npm dependencies in Meteor 1.3+ Atmosphere packages.
TypeScript
11
star
36

meteor-browser-tests

A helper package for Meteor test driver packages. Runs client tests in a headless browser.
JavaScript
11
star
37

template-package

Template package with CI and everything else to get started quickly with creating a new FOSS Meteor package.
JavaScript
10
star
38

meteor-stylus

A fork of meteor:stylus with mquandalle:stylus plugins
JavaScript
8
star
39

meteor-minifiers-autoprefix

JavaScript
6
star
40

meteor-autoform-bs-button-group-input

A Bootstrap button group theme for the "select-checkbox" and "select-radio" AutoForm input types
JavaScript
6
star
41

ground-minimax

Minimax is a thin layer for Meteor providing EJSON.minify and EJSON.maxify
JavaScript
6
star
42

meteor-typescript

Typescript compiler package
TypeScript
5
star
43

meteor-api-untethered

A collection of packages to make Meteor available to other environments.
JavaScript
5
star
44

awesome-meteor

Curated list of awesome Meteor.js things.
5
star
45

Meteor-EventState

DEPRECATED: Evented state
JavaScript
4
star
46

meteor-autoform-themes

Officially supported themes for aldeed:autoform
JavaScript
3
star
47

push

JavaScript
2
star