Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated some documentation #319

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

[*.md]
trim_trailing_whitespace = false
max_line_length = 80
indent_style = space
indent_size = 3
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.md -whitespace
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

**1.0.1**
* Marked required Node version v4.0

**1.0.0**
* Dependency bump

**0.14.6**
* Support for ios mutable-content (PR #297, thanks @SemonCat)

Expand Down
32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# node-gcm

[![Join the chat at https://gitter.im/ToothlessGear/node-gcm](https://badges.gitter.im/ToothlessGear/node-gcm.svg)](https://gitter.im/ToothlessGear/node-gcm?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![npm](https://badge.fury.io/js/node-gcm.svg)](https://www.npmjs.com/package/node-gcm)
[![npm](https://badge.fury.io/js/node-gcm.svg)](https://www.npmjs.com/package/node-gcm)
[![dependencies Status](https://david-dm.org/ToothlessGear/node-gcm/status.svg)](https://david-dm.org/ToothlessGear/node-gcm)
[![optionalDependencies Status](https://david-dm.org/ToothlessGear/node-gcm/optional-status.svg)](https://david-dm.org/ToothlessGear/node-gcm?type=optional)
[![devDependencies Status](https://david-dm.org/ToothlessGear/node-gcm/dev-status.svg)](https://david-dm.org/ToothlessGear/node-gcm?type=dev)


The goal of this project is providing the best and most easily used interface for Firebase Cloud Messaging. (The name `gcm` comes from the older name for the service, Google Cloud Messaging.)

Expand Down Expand Up @@ -46,7 +50,7 @@ var sender = new gcm.Sender('YOUR_API_KEY_HERE');

// Prepare a message to be sent
var message = new gcm.Message({
data: { key1: 'msg1' }
data: { key1: 'msg1' }
});

// Specify which registration IDs to deliver the message to
Expand Down Expand Up @@ -110,20 +114,20 @@ registrationTokens.push('regToken2');
// Send the message
// ... trying only once
sender.sendNoRetry(message, { registrationTokens: registrationTokens }, function(err, response) {
if(err) console.error(err);
else console.log(response);
if(err) console.error(err);
else console.log(response);
});

// ... or retrying
sender.send(message, { registrationTokens: registrationTokens }, function (err, response) {
if(err) console.error(err);
else console.log(response);
if(err) console.error(err);
else console.log(response);
});

// ... or retrying a specific number of times (10)
sender.send(message, { registrationTokens: registrationTokens }, 10, function (err, response) {
if(err) console.error(err);
else console.log(response);
if(err) console.error(err);
else console.log(response);
});
```
## Recipients
Expand Down Expand Up @@ -162,7 +166,6 @@ This is due to [a restriction](http://developer.android.com/training/cloudsync/g
## Notification usage

```js

var message = new gcm.Message();

// Add notification payload as key value
Expand All @@ -172,11 +175,10 @@ message.addNotification('icon', 'ic_launcher');

// as object
message.addNotification({
title: 'Alert!!!',
body: 'Abnormal data access',
icon: 'ic_launcher'
title: 'Alert!!!',
body: 'Abnormal data access',
icon: 'ic_launcher'
});

```

**Note:** Notifications sent using `message.addNotification` are only displayed when your app is in the background. Consider sending the notification parameters using `message.addData` and manually building and displaying a notification in your push receiver logic.
Expand Down Expand Up @@ -218,8 +220,8 @@ var sender = new gcm.Sender('YOUR_API_KEY_HERE', requestOptions);

// Send it to GCM endpoint with modified request options
sender.send(message, { registrationTokens: regTokens }, function (err, response) {
if(err) console.error(err);
else console.log(response);
if(err) console.error(err);
else console.log(response);
});
```

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"Marc Obrador <[email protected]> (https://github.com/marcobrador)",
"Chirag Choudhary <[email protected]> (https://github.com/chirag200666)",
"Alexander Amin <[email protected]> (https://github.com/AlexAmin)",
"Gaurav Nolkha <[email protected]> (https://github.com/vibgy)"
"Gaurav Nolkha <[email protected]> (https://github.com/vibgy)",
"Jan Kowalleck <[email protected]> (https://github.com/jkowalleck)"
],
"repository": {
"type": "git",
Expand Down