Skip to content

Commit

Permalink
v1.4.0-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
jpatel531 committed Jul 18, 2016
1 parent bbb8fce commit fbc5381
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,68 @@ var socketId = '1302.1081607';
pusher.trigger(channel, event, data, socketId);
```

### Push Notifications [BETA]

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:

$ npm install [email protected]

#### Sending native pushes

The native notifications API is hosted at `nativepushclient-cluster1.pusher.com` and only accepts https requests.

You can send pushes by using the `notify` method, either globally or on the instance. The method takes two parameters:

- `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.
- `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).

Example:

```js
var data = {
apns: {
priority: 5,
aps: {
alert: {
body: 'tada'
}
}
}
}

pusher.notify(["my-favourite-interest"], data)
```

#### Errors

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.

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.

For example:

```js
var data = {
"apns": {
"aps": {
"alert": {
"body": "hello"
}
}
},
'gcm': {
'notification': {
"title": "hello",
"icon": "icon"
}
},
"webhook_url": "http://yolo.com",
"webhook_level": "INFO"
}
```

**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]([email protected]) or create an issue here.

### Authenticating private channels

To authorise your users to access private channels on Pusher, you can use the `authenticate` function:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pusher",
"description": "Node.js client to interact with the Pusher REST API",
"version": "1.3.0",
"version": "1.4.0-rc1",
"author": "Pusher <[email protected]>",
"contributors": [
{
Expand Down

0 comments on commit fbc5381

Please sign in to comment.