pushpad 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -10
- data/lib/pushpad.rb +6 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d5da8a00cef1d996040436cba21c10f9f79477d
|
4
|
+
data.tar.gz: cdce085f47c1ee64f3883a13cde521044aa24a06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9432d8acaa2e1a1dc0bc97b10b96e51d17a4737cfe0e737da6af0b7af71cdee342920c6de9ddf4efb4dd53042c179a6bc409e39d29ad5bb96b44b91fbe93873
|
7
|
+
data.tar.gz: 759357bab59b8f1a35296cdaced26f7f1831895e731eb4aab63788c03e73e119d2f120fe17e2d9c198d857f51a45e18ceac9112177dab244d7df34a9de21a5e6
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# Pushpad - Web Push Notifications
|
2
|
-
|
3
|
-
|
1
|
+
# Pushpad - Web Push Notifications Service
|
2
|
+
|
3
|
+
[Pushpad](https://pushpad.xyz) is a service for sending push notifications from your web app. It supports the **Push API** (Chrome and Firefox) and **APNs** (Safari).
|
4
4
|
|
5
5
|
Features:
|
6
6
|
|
@@ -60,17 +60,16 @@ Pushpad.signature_for current_user.id
|
|
60
60
|
|
61
61
|
### Pushpad Express
|
62
62
|
|
63
|
-
|
63
|
+
If you want to use Pushpad Express, add a link to your website to let users subscribe to push notifications:
|
64
64
|
|
65
65
|
```erb
|
66
|
-
<a href="<%= Pushpad.path %>">
|
66
|
+
<a href="<%= Pushpad.path %>">Push notifications</a>
|
67
67
|
|
68
|
-
|
68
|
+
<!-- If the user is logged in on your website you should track its user id to target him in the future -->
|
69
|
+
<a href="<%= Pushpad.path_for current_user # or current_user_id %>">Push notifications</a>
|
69
70
|
```
|
70
71
|
|
71
|
-
|
72
|
-
|
73
|
-
When a user clicks the link is sent to Pushpad, automatically asked to receive push notifications and redirected back to your website.
|
72
|
+
When a user clicks the link is sent to Pushpad, asked to receive push notifications and redirected back to your website.
|
74
73
|
|
75
74
|
## Sending push notifications
|
76
75
|
|
@@ -78,7 +77,9 @@ When a user clicks the link is sent to Pushpad, automatically asked to receive p
|
|
78
77
|
notification = Pushpad::Notification.new({
|
79
78
|
body: "Hello world!", # max 90 characters
|
80
79
|
title: "Website Name", # optional, defaults to your project name, max 30 characters
|
81
|
-
target_url: "http://example.com" # optional, defaults to your project website
|
80
|
+
target_url: "http://example.com", # optional, defaults to your project website
|
81
|
+
icon_url: "http://example.com/assets/icon.png", # optional, defaults to the project icon
|
82
|
+
ttl: 604800 # optional, drop the notification after this number of seconds if a device is offline
|
82
83
|
})
|
83
84
|
|
84
85
|
# deliver to a user
|
@@ -102,6 +103,7 @@ If no user with that id has subscribed to push notifications, that id is simply
|
|
102
103
|
|
103
104
|
The methods above return an hash:
|
104
105
|
|
106
|
+
- `"id"` is the id of the notification on Pushpad
|
105
107
|
- `"scheduled"` is the number of devices to which the notification will be sent
|
106
108
|
- `"uids"` (`deliver_to` only) are the user IDs that will be actually reached by the notification (unless they have unsubscribed since the last notification)
|
107
109
|
|
data/lib/pushpad.rb
CHANGED
@@ -43,12 +43,14 @@ module Pushpad
|
|
43
43
|
class DeliveryError < RuntimeError
|
44
44
|
end
|
45
45
|
|
46
|
-
attr_accessor :body, :title, :target_url
|
46
|
+
attr_accessor :body, :title, :target_url, :icon_url, :ttl
|
47
47
|
|
48
48
|
def initialize(options)
|
49
49
|
self.body = options[:body]
|
50
50
|
self.title = options[:title]
|
51
51
|
self.target_url = options[:target_url]
|
52
|
+
self.icon_url = options[:icon_url]
|
53
|
+
self.ttl = options[:ttl]
|
52
54
|
end
|
53
55
|
|
54
56
|
def broadcast(options = {})
|
@@ -96,7 +98,9 @@ module Pushpad
|
|
96
98
|
"notification" => {
|
97
99
|
"body" => self.body,
|
98
100
|
"title" => self.title,
|
99
|
-
"target_url" => self.target_url
|
101
|
+
"target_url" => self.target_url,
|
102
|
+
"icon_url" => self.icon_url,
|
103
|
+
"ttl" => self.ttl
|
100
104
|
}
|
101
105
|
}
|
102
106
|
body["uids"] = uids if uids
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pushpad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pushpad
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|