diff --git a/README.md b/README.md index 8786d6b..ccd4b64 100644 --- a/README.md +++ b/README.md @@ -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 pusher@1.4.0-rc1 + +#### 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](support@pusher.com) or create an issue here. + ### Authenticating private channels To authorise your users to access private channels on Pusher, you can use the `authenticate` function: diff --git a/package.json b/package.json index 33b9681..9b83918 100644 --- a/package.json +++ b/package.json @@ -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 ", "contributors": [ {