pushpad 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +11 -4
- data/lib/pushpad.rb +5 -3
- 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: a1bdf804e269c7ee9bcb0684030849617c955e98
|
4
|
+
data.tar.gz: c0da7ef0194d0950671c86154e2bc45d0d6507b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8f8d324fe7068c3bc4fb0744637e311106146849a4fb0ccea0183b431d2ef7ae3a82313fa690143eda9a3a865b4ae961d44129c013566b9f0f5fd68d49a78b7
|
7
|
+
data.tar.gz: db783ff3ebc5215fe7f9bf7315fa3f3debb13b48ae5ddc545471ceb3d514d7a95cb63199ff3cc4dc1bf27d78e240de094146f8236cb7d033cb7ec92ce7c533a2
|
data/README.md
CHANGED
@@ -75,11 +75,12 @@ When a user clicks the link is sent to Pushpad, asked to receive push notificati
|
|
75
75
|
|
76
76
|
```ruby
|
77
77
|
notification = Pushpad::Notification.new({
|
78
|
-
body: "Hello world!", # max
|
78
|
+
body: "Hello world!", # max 120 characters
|
79
79
|
title: "Website Name", # optional, defaults to your project name, max 30 characters
|
80
80
|
target_url: "http://example.com", # optional, defaults to your project website
|
81
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
|
+
ttl: 604800, # optional, drop the notification after this number of seconds if a device is offline
|
83
|
+
require_interaction: true # optional, default is false, if true it prevents Chrome from automatically closing the notification after a few seconds
|
83
84
|
})
|
84
85
|
|
85
86
|
# deliver to a user
|
@@ -93,8 +94,14 @@ notification.deliver_to users # or user_ids
|
|
93
94
|
notification.deliver_to users, tags: ['events']
|
94
95
|
|
95
96
|
# deliver to segments
|
97
|
+
# e.g. any subscriber that has the tag "segment1" OR "segment2"
|
96
98
|
notification.broadcast tags: ['segment1', 'segment2']
|
97
99
|
|
100
|
+
# you can use boolean expressions
|
101
|
+
# they must be in the disjunctive normal form (without parenthesis)
|
102
|
+
notification.broadcast tags: ['zip_code:28865 && !optout:local_events || friend_of:Organizer123']
|
103
|
+
notification.deliver_to users, tags: ['tag1 && tag2', 'tag3'] # equal to 'tag1 && tag2 || tag3'
|
104
|
+
|
98
105
|
# deliver to everyone
|
99
106
|
notification.broadcast
|
100
107
|
```
|
@@ -104,8 +111,8 @@ If no user with that id has subscribed to push notifications, that id is simply
|
|
104
111
|
The methods above return an hash:
|
105
112
|
|
106
113
|
- `"id"` is the id of the notification on Pushpad
|
107
|
-
- `"scheduled"` is the number of devices to which the notification will be sent
|
108
|
-
- `"uids"` (`deliver_to` only) are the user IDs that will be actually reached by the notification
|
114
|
+
- `"scheduled"` is the estimated reach of the notification (i.e. the number of devices to which the notification will be sent, which can be different from the number of users, since a user may receive notifications on multiple devices)
|
115
|
+
- `"uids"` (`deliver_to` only) are the user IDs that will be actually reached by the notification because they are subscribed to your notifications. For example if you send a notification to `['uid1', 'uid2', 'uid3']`, but only `'uid1'` is subscribed, you will get `['uid1']` in response. Note that if a user has unsubscribed after the last notification sent to him, he may still be reported for one time as subscribed (this is due to [the way](http://blog.pushpad.xyz/2016/05/the-push-api-and-its-wild-unsubscription-mechanism/) the W3C Push API works).
|
109
116
|
|
110
117
|
## License
|
111
118
|
|
data/lib/pushpad.rb
CHANGED
@@ -36,14 +36,14 @@ module Pushpad
|
|
36
36
|
def self.path_for(user, options = {})
|
37
37
|
uid = user.respond_to?(:id) ? user.id : user
|
38
38
|
uid_signature = self.signature_for(uid.to_s)
|
39
|
-
"#{self.path(options)}?uid=#{uid}&uid_signature=#{uid_signature}"
|
39
|
+
"#{self.path(options)}?uid=#{uid}&uid_signature=#{uid_signature}"
|
40
40
|
end
|
41
41
|
|
42
42
|
class Notification
|
43
43
|
class DeliveryError < RuntimeError
|
44
44
|
end
|
45
45
|
|
46
|
-
attr_accessor :body, :title, :target_url, :icon_url, :ttl
|
46
|
+
attr_accessor :body, :title, :target_url, :icon_url, :ttl, :require_interaction
|
47
47
|
|
48
48
|
def initialize(options)
|
49
49
|
self.body = options[:body]
|
@@ -51,6 +51,7 @@ module Pushpad
|
|
51
51
|
self.target_url = options[:target_url]
|
52
52
|
self.icon_url = options[:icon_url]
|
53
53
|
self.ttl = options[:ttl]
|
54
|
+
self.require_interaction = !!options[:require_interaction]
|
54
55
|
end
|
55
56
|
|
56
57
|
def broadcast(options = {})
|
@@ -100,7 +101,8 @@ module Pushpad
|
|
100
101
|
"title" => self.title,
|
101
102
|
"target_url" => self.target_url,
|
102
103
|
"icon_url" => self.icon_url,
|
103
|
-
"ttl" => self.ttl
|
104
|
+
"ttl" => self.ttl,
|
105
|
+
"require_interaction" => self.require_interaction
|
104
106
|
}
|
105
107
|
}
|
106
108
|
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.5.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-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|