pushpad 0.1.6 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +28 -12
- 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: 280dfb492f2142c46bc48aab853d09a1d2a6c8a8
|
4
|
+
data.tar.gz: 30ae77b7b02d8c1f989f24870f2ed8f0918add83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3889d1b96e444ded703aa7900c2b47abc1462aae58dec4ac937103efc2dde2d4d34ea9e6f7532f4e8a0abc755f63b692ff1db96c6ca37416ff15089648927f37
|
7
|
+
data.tar.gz: 83589e468d60ae8fde4af1239a9349bf916f09da1a509502483d462ffc33132a2314b68e1f1da169837789e04e1eb7ac71a8d71a8b3c93a835a9343968ce3962
|
data/README.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
-
# Pushpad:
|
1
|
+
# Pushpad: real push notifications for websites
|
2
2
|
|
3
|
-
Add
|
3
|
+
Add native push notifications to your web app using [Pushpad](https://pushpad.xyz).
|
4
|
+
|
5
|
+
Features:
|
6
|
+
|
7
|
+
- notifications are delivered even when the user is not on your website
|
8
|
+
- users don't need to install any app or plugin
|
9
|
+
- you can target specific users or send bulk notifications
|
4
10
|
|
5
11
|
Currently push notifications work on the following browsers:
|
6
12
|
|
@@ -8,12 +14,6 @@ Currently push notifications work on the following browsers:
|
|
8
14
|
- Firefox (44+)
|
9
15
|
- Safari
|
10
16
|
|
11
|
-
Features:
|
12
|
-
|
13
|
-
- users don't need to install any app or plugin
|
14
|
-
- notifications are delivered even when the user is not on your website
|
15
|
-
- you can target specific users or send bulk notifications
|
16
|
-
|
17
17
|
## Installation
|
18
18
|
|
19
19
|
Add this line to your application's Gemfile:
|
@@ -30,13 +30,13 @@ Or install it yourself as:
|
|
30
30
|
|
31
31
|
$ gem install pushpad
|
32
32
|
|
33
|
-
##
|
33
|
+
## Getting started
|
34
34
|
|
35
|
-
First you need to sign up to Pushpad and create a project there.
|
35
|
+
First you need to sign up to Pushpad and create a project there.
|
36
36
|
|
37
37
|
Then set your authentication credentials:
|
38
38
|
|
39
|
-
```
|
39
|
+
```ruby
|
40
40
|
Pushpad.auth_token = '5374d7dfeffa2eb49965624ba7596a09'
|
41
41
|
Pushpad.project_id = 123 # set it here or pass it as a param to methods later
|
42
42
|
```
|
@@ -44,6 +44,20 @@ Pushpad.project_id = 123 # set it here or pass it as a param to methods later
|
|
44
44
|
`auth_token` can be found in the user account settings.
|
45
45
|
`project_id` can be found in the project settings on Pushpad. A project is a list of subscriptions. You can set it globally or pass it as a param to methods if your app uses multiple lists (e.g. `Pushpad.path_for current_user, project_id: 123`, `notification.deliver_to user, project_id: 123`).
|
46
46
|
|
47
|
+
## Collecting user subscriptions
|
48
|
+
|
49
|
+
### Custom API
|
50
|
+
|
51
|
+
Read the [docs](https://pushpad.xyz/docs#custom_api_docs).
|
52
|
+
|
53
|
+
If you need to generate the HMAC signature for the `uid` you can use this helper:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
Pushpad.signature_for current_user.id
|
57
|
+
```
|
58
|
+
|
59
|
+
### Simple API
|
60
|
+
|
47
61
|
Let users subscribe to your push notifications:
|
48
62
|
|
49
63
|
```erb
|
@@ -56,7 +70,9 @@ Let users subscribe to your push notifications:
|
|
56
70
|
|
57
71
|
When a user clicks the link is sent to Pushpad, automatically asked to receive push notifications and redirected back to your website.
|
58
72
|
|
59
|
-
|
73
|
+
## Sending notifications
|
74
|
+
|
75
|
+
After you have collected the user subscriptions you can send them push notifications:
|
60
76
|
|
61
77
|
```ruby
|
62
78
|
notification = Pushpad::Notification.new({
|
data/lib/pushpad.rb
CHANGED
@@ -22,6 +22,11 @@ module Pushpad
|
|
22
22
|
@@project_id = project_id
|
23
23
|
end
|
24
24
|
|
25
|
+
def self.signature_for(data)
|
26
|
+
raise "You must set Pushpad.auth_token" unless Pushpad.auth_token
|
27
|
+
OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), self.auth_token, data.to_s)
|
28
|
+
end
|
29
|
+
|
25
30
|
def self.path(options = {})
|
26
31
|
project_id = options[:project_id] || self.project_id
|
27
32
|
raise "You must set project_id" unless project_id
|
@@ -29,9 +34,8 @@ module Pushpad
|
|
29
34
|
end
|
30
35
|
|
31
36
|
def self.path_for(user, options = {})
|
32
|
-
raise "You must set Pushpad.auth_token" unless Pushpad.auth_token
|
33
37
|
uid = user.respond_to?(:id) ? user.id : user
|
34
|
-
uid_signature =
|
38
|
+
uid_signature = self.signature_for(uid.to_s)
|
35
39
|
"#{self.path(options)}?uid=#{uid}&uid_signature=#{uid_signature}"
|
36
40
|
end
|
37
41
|
|
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.1
|
4
|
+
version: 0.2.1
|
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-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|