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
Copy file name to clipboardExpand all lines: README.md
+62
Original file line number
Diff line number
Diff line change
@@ -153,6 +153,68 @@ var socketId = '1302.1081607';
153
153
pusher.trigger(channel, event, data, socketId);
154
154
```
155
155
156
+
### Push Notifications [BETA]
157
+
158
+
Pusher now allows sending native notifications to iOS and Android devices. Check out the [documentation](https://pusher.com/docs/push_notifications) for information on how to set up push notifications on Android and iOS. There is no additional setup required to use it with this library. It works out of the box wit the same Pusher instance. All you need are the same pusher credentials. To install the release candidate:
159
+
160
+
$ npm install pusher@1.4.0-rc1
161
+
162
+
#### Sending native pushes
163
+
164
+
The native notifications API is hosted at `nativepushclient-cluster1.pusher.com` and only accepts https requests.
165
+
166
+
You can send pushes by using the `notify` method, either globally or on the instance. The method takes two parameters:
167
+
168
+
-`interests`: An Array of strings which represents the interests your devices are subscribed to. These are akin to channels in the DDN with less of an epehemeral nature. Note that currently, you can only send to _one_ interest.
169
+
-`data`: The content of the notification represented by a Hash. You must supply either the `gcm` or `apns` key. For a detailed list of the acceptable keys, take a look at the [docs](https://pusher.com/docs/push_notifications#payload).
170
+
171
+
Example:
172
+
173
+
```js
174
+
var data = {
175
+
apns: {
176
+
priority:5,
177
+
aps: {
178
+
alert: {
179
+
body:'tada'
180
+
}
181
+
}
182
+
}
183
+
}
184
+
185
+
pusher.notify(["my-favourite-interest"], data)
186
+
```
187
+
188
+
#### Errors
189
+
190
+
Push notification requests, once submitted to the service are executed asynchronously. To make reporting errors easier, you can supply a `webhook_url` field in the body of the request. This will be used by the service to send a webhook to the supplied URL if there are errors.
191
+
192
+
You may also supply a `webhook_level` field in the body, which can either be INFO or DEBUG. It defaults to INFO - where INFO only reports customer facing errors, while DEBUG reports all errors.
193
+
194
+
For example:
195
+
196
+
```js
197
+
var data = {
198
+
"apns": {
199
+
"aps": {
200
+
"alert": {
201
+
"body":"hello"
202
+
}
203
+
}
204
+
},
205
+
'gcm': {
206
+
'notification': {
207
+
"title":"hello",
208
+
"icon":"icon"
209
+
}
210
+
},
211
+
"webhook_url":"http://yolo.com",
212
+
"webhook_level":"INFO"
213
+
}
214
+
```
215
+
216
+
**NOTE:** This is currently a BETA feature and there might be minor bugs and issues. Changes to the API will be kept to a minimum, but changes are expected. If you come across any bugs or issues, please do get in touch via [support](support@pusher.com) or create an issue here.
217
+
156
218
### Authenticating private channels
157
219
158
220
To authorise your users to access private channels on Pusher, you can use the `authenticate` function:
0 commit comments