You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sender.send(message, { registrationTokens: registrationTokens }, function (err, response) {
87
+
gcm.send(message, { registrationTokens: registrationTokens }, function (err, response) {
109
88
if(err) console.error(err);
110
89
elseconsole.log(response);
111
90
});
112
91
113
92
// ... or retrying a specific number of times (10)
114
-
sender.send(message, { registrationTokens: registrationTokens }, 10, function (err, response) {
93
+
gcm.send(message, { registrationTokens: registrationTokens }, 10, function (err, response) {
115
94
if(err) console.error(err);
116
95
elseconsole.log(response);
117
96
});
118
97
```
98
+
119
99
## Recipients
120
100
121
101
You can send push notifications to various recipient types by providing one of the following recipient keys:
122
102
123
-
124
103
|Key|Type|Description|
125
104
|---|---|---|
126
105
|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).
@@ -137,21 +116,13 @@ This is due to [a restriction](http://developer.android.com/training/cloudsync/g
137
116
## Notification usage
138
117
139
118
```js
140
-
141
-
var message =newgcm.Message();
142
-
143
-
// Add notification payload as key value
144
-
message.addNotification('title', 'Alert!!!');
145
-
message.addNotification('body', 'Abnormal data access');
146
-
message.addNotification('icon', 'ic_launcher');
147
-
148
-
// as object
149
-
message.addNotification({
150
-
title:'Alert!!!',
151
-
body:'Abnormal data access',
152
-
icon:'ic_launcher'
153
-
});
154
-
119
+
var message = {
120
+
notification: {
121
+
title:'Alert!!!',
122
+
body:'Abnormal data access',
123
+
icon:'ic_launcher'
124
+
}
125
+
};
155
126
```
156
127
157
128
### Notification payload option table
@@ -184,13 +155,13 @@ var requestOptions = {
184
155
timeout:5000
185
156
};
186
157
187
-
// Set up the sender with your API key and request options
0 commit comments