Skip to content

Commit 5a13c4c

Browse files
committed
Update readme
1 parent 525f405 commit 5a13c4c

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,74 @@ else
247247
render text: 'invalid', status: 401
248248
end
249249
```
250+
251+
## Push Notifications (BETA)
252+
253+
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.
254+
255+
You can set the `notification_host` globally like so
256+
257+
```ruby
258+
Pusher.notification_host = "<host>.com"
259+
```
260+
The default host is set to `<insert endpoint here>` and is currently the only supported host.
261+
262+
Alternatively, you may set it on an instance of Pusher
263+
264+
```ruby
265+
pusher.notification_host = "<host>.com"
266+
```
267+
268+
You can also set a scheme for the notification host like above by specifying the `notification_scheme` key in the options hash or by setting it globally.
269+
270+
### Sending native pushes
271+
272+
You can send pushes by using the `notify` method, either globally or on the instance. The method takes two parameters:
273+
274+
- `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.
275+
- `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).
276+
277+
Example:
278+
279+
```ruby
280+
data = {
281+
apns: {
282+
alert: {
283+
body: 'tada'
284+
}
285+
}
286+
}
287+
288+
pusher.notify(["my-favourite-interest"], data)
289+
```
290+
291+
You may similarly use this method globally too.
292+
293+
### Errors
294+
295+
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.
296+
297+
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.
298+
299+
For example:
300+
301+
```ruby
302+
data = {
303+
apns: {
304+
alert: {
305+
body: "hello"
306+
}
307+
},
308+
gcm: {
309+
notification: {
310+
title: "hello",
311+
icon: "icon"
312+
}
313+
},
314+
webhook_url: "http://yolo.com",
315+
webhook_level: "INFO"
316+
}
317+
```
318+
319+
**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.
320+

0 commit comments

Comments
 (0)