Skip to content

Commit a3dcac0

Browse files
committed
More adjustments to the README
1 parent 3a5fe3f commit a3dcac0

1 file changed

Lines changed: 10 additions & 19 deletions

File tree

README.md

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ gcm.send(message, { registrationTokens: registrationTokens }, 10, function (err,
100100

101101
You can send push notifications to various recipient types by providing one of the following recipient keys:
102102

103-
104103
|Key|Type|Description|
105104
|---|---|---|
106105
|to|String|A single [registration token](https://developers.google.com/cloud-messaging/android/client#sample-register), [notification key](https://developers.google.com/cloud-messaging/notifications), or [topic](https://developers.google.com/cloud-messaging/topic-messaging).
@@ -117,21 +116,13 @@ This is due to [a restriction](http://developer.android.com/training/cloudsync/g
117116
## Notification usage
118117

119118
```js
120-
121-
var message = new gcm.Message();
122-
123-
// Add notification payload as key value
124-
message.addNotification('title', 'Alert!!!');
125-
message.addNotification('body', 'Abnormal data access');
126-
message.addNotification('icon', 'ic_launcher');
127-
128-
// as object
129-
message.addNotification({
130-
title: 'Alert!!!',
131-
body: 'Abnormal data access',
132-
icon: 'ic_launcher'
133-
});
134-
119+
var message = {
120+
notification: {
121+
title: 'Alert!!!',
122+
body: 'Abnormal data access',
123+
icon: 'ic_launcher'
124+
}
125+
};
135126
```
136127

137128
### Notification payload option table
@@ -164,13 +155,13 @@ var requestOptions = {
164155
timeout: 5000
165156
};
166157

167-
// Set up the sender with your API key and request options
168-
var sender = new gcm.Sender('YOUR_API_KEY_HERE', requestOptions);
158+
// Set up gcm with your API key and request options
159+
var gcm = require("node-gcm")('YOUR_API_KEY_HERE', requestOptions);
169160

170161
// Prepare a GCM message...
171162

172163
// Send it to GCM endpoint with modified request options
173-
sender.send(message, { registrationTokens: regTokens }, function (err, response) {
164+
gcm.send(message, { registrationTokens: regTokens }, function (err, response) {
174165
if(err) console.error(err);
175166
else console.log(response);
176167
});

0 commit comments

Comments
 (0)