pushpad 0.3.1 → 0.4.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -10
  3. data/lib/pushpad.rb +6 -2
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eacf67b455e6c7f2fc9a23523811381178bcba19
4
- data.tar.gz: 02e738b3b27f51972f856acc984ffb753cdf6998
3
+ metadata.gz: 5d5da8a00cef1d996040436cba21c10f9f79477d
4
+ data.tar.gz: cdce085f47c1ee64f3883a13cde521044aa24a06
5
5
  SHA512:
6
- metadata.gz: 9205b965cef3e6d66aeb5a1d18f0a38ef009d6d58f0639a0b4f80657a0759ce090d11dafaa03299366bbb611b3d131b7913d29516b29162be4ff68fa2a22cf18
7
- data.tar.gz: fda326dceba48f7672b20a2c48dc2e750bda53c4e29d6f9567e4747c7e114201c8f640179ffc30af064b8d3068e76c2fd481a4f6dd9c818a76605252ad6b463e
6
+ metadata.gz: c9432d8acaa2e1a1dc0bc97b10b96e51d17a4737cfe0e737da6af0b7af71cdee342920c6de9ddf4efb4dd53042c179a6bc409e39d29ad5bb96b44b91fbe93873
7
+ data.tar.gz: 759357bab59b8f1a35296cdaced26f7f1831895e731eb4aab63788c03e73e119d2f120fe17e2d9c198d857f51a45e18ceac9112177dab244d7df34a9de21a5e6
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Pushpad - Web Push Notifications
2
-
3
- Add native push notifications to your web app using [Pushpad](https://pushpad.xyz).
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
- Add a link to let users subscribe to push notifications:
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 %>">Subscribe anonymous to push notifications</a>
66
+ <a href="<%= Pushpad.path %>">Push notifications</a>
67
67
 
68
- <a href="<%= Pushpad.path_for current_user # or current_user_id %>">Subscribe current user to push notifications</a>
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
- `current_user` is the user currently logged in on your website.
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
 
@@ -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.3.1
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-05-26 00:00:00.000000000 Z
11
+ date: 2016-07-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: