npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-gcm-ccs

v0.0.1

Published

Google Cloud Messaging via XMPP

Downloads

4

Readme

Getting Started

Install via

npm install git+https://github.com/jacobp100/node-gcm-ccs.git

Use via

var GCM = require('node-gcm-ccs');
var gcm = GCM(<project number>, <api key>);

Getting an API Key

  • Go to https://console.developers.google.com, create a project and open it
  • Navigate to overview, and you'll see your <project id> at the top
  • Go to APIs & auth -> APIs, add Google Cloud Messaging for Android
  • Go to APIs & auth -> credentials, and create a new public <api key>

Functions

Send Message

Use send to send a message.

gcm.send(to, data, [options, callback(error, messageId, to)]);

Argument | Details ------------------- | ------- to | A single user data | Data to be sent to the client options (optional) | See Message Paremeters from https://developer.android.com/google/gcm/server.html#send-msg. If delivery_receipt_requested = true, an event will be sent when the message is received by the target. callback (optional) | function(error, messageId, to) called back individually for each target.

End Connection

gcm.end;

Events

Events are defined as below.

gcm.on('message', function(messageId, from, category, data)); // Messages received from client (excluding receipts)
gcm.on('receipt', function(messageId, from, category, data)); // Only fired for messages where options.delivery_receipt_requested = true

gcm.on('connected', console.log);
gcm.on('disconnected', console.log);
gcm.on('online', console.log);
gcm.on('error', console.log);

Example

var GCM = require('node-gcm-ccs');
var gcm = GCM(<project id>, <api key>);

gcm.on('message', function(messageId, from, category, data) {
	console.log('received message', arguments);
});

gcm.on('receipt', function(messageId, from, category, data) {
	console.log('received receipt', arguments);
});

gcm.send(<device id>, { message: 'hello world' }, { delivery_receipt_requested: true }, function(err, messageId, to)) {
	if (!err) {
		console.log('sent message to', to, 'with message_id =', messageId);
	} else {
		console.log('failed to send message');
	}
}

Echo Client

gcm.on('message', function(_, from, __, data) {
	gcm.send(from, data);
});

Notes on GCM

  • No events are emitted from GCM or this library when a device new registers: you'll have to send a message from the device and process it yourself
  • This library doesn't have functions to create user notifications (https://developer.android.com/google/gcm/notifications.html). However, if you implement this yourself, you'll be able to send to a user group by paassing the notification_key_name as a device_id for gcm.send.
  • Occasionally, GCM performs load balancing, so the connection is sometimes restarted. This library handles this transparently, and your messages will be queued in these situations.