grocer 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.travis.yml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +49 -72
- data/images/Creating_the_Push_Notification_Certificate.png +0 -0
- data/lib/grocer/extensions/deep_symbolize_keys.rb +2 -1
- data/lib/grocer/version.rb +1 -1
- metadata +29 -25
- data/images/Downloading_the_Push_Notification_Certificate.png +0 -0
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ZDRlNTFjOTRhOGI4NzAyNzU3YjEwZjhmNzZhNTcyMmM0Y2QxZTQ3MA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 75905d43e4c20c6e907667758001df9afe1d504d
|
4
|
+
data.tar.gz: 6eb2736ad5455fae0eddc8541cd025d5713cae37
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
YzI4NTEwNGYyN2ViMDFjMWNiYWQ0NGRiOGYzM2Y1YTA4MTVlYzY1MTI2YTU5
|
11
|
-
MjM2M2U4MzQ2Yzc2MDEyOWQ2MDQ4ZDNkOWJkZjZmNzcxYzkyOTE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MTE4YzBiODQ2M2NlNmE0MTJmMzY1NGE2OTBmODc4ZTY5NDY3OGE2MjkxMzMz
|
14
|
-
YWQyMjcwOTM2NDBlYjRkMmFlOWRmZjk4MDRmMjllZmRlYzU0YjQ3ZGJlY2I5
|
15
|
-
MGYwN2QyY2VmZmIwYThhNGI0ZjEyZWM2YTVkMDA4Y2U3OTExMTE=
|
6
|
+
metadata.gz: 75833048b5daface771a1e56a0c0cb81a2de9d37945077e7aa1577c21f2f9dab687333440d26634427446e641b16c0d87efca5b9909f26fc03f74a212511997d
|
7
|
+
data.tar.gz: 780a1bbb33f9017d386f5a56a15cf4e693a37a889a50cea4a56508c18d88b99538e6af4bbafdecf08b56f03517aafd25ad94c7b5a8cb31f1e0f6ff75a854d2b9
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -5,9 +5,7 @@
|
|
5
5
|
[![Build Status](https://img.shields.io/travis/grocer/grocer.svg)](https://travis-ci.org/grocer/grocer)
|
6
6
|
[![Dependency Status](https://img.shields.io/gemnasium/grocer/grocer.svg)](https://gemnasium.com/grocer/grocer)
|
7
7
|
|
8
|
-
**grocer** interfaces with the [Apple Push Notification
|
9
|
-
Service](http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html)
|
10
|
-
to send push notifications to iOS devices.
|
8
|
+
**grocer** interfaces with the [Apple Push Notification Service](http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html) to send push notifications to iOS devices.
|
11
9
|
|
12
10
|
There are other gems out there to do this, but **grocer** plans to be the cleanest, most extensible, and friendliest.
|
13
11
|
|
@@ -65,17 +63,11 @@ pusher = Grocer.pusher(
|
|
65
63
|
|
66
64
|
#### Notes
|
67
65
|
|
68
|
-
* `certificate`: If you don't have the certificate stored in a file, you
|
69
|
-
can pass any object that responds to `read`.
|
66
|
+
* `certificate`: If you don't have the certificate stored in a file, you can pass any object that responds to `read`.
|
70
67
|
Example: `certificate: StringIO.new(pem_string)`
|
71
|
-
* `gateway`: Defaults to different values depending on the `RAILS_ENV` or
|
72
|
-
`
|
73
|
-
|
74
|
-
[Acceptance Testing](#acceptance-testing) later), otherwise defaults to
|
75
|
-
`gateway.sandbox.push.apple.com`.
|
76
|
-
* `retries`: The number of times **grocer** will retry writing to or reading
|
77
|
-
from the Apple Push Notification Service before raising any errors to client
|
78
|
-
code.
|
68
|
+
* `gateway`: Defaults to different values depending on the `RAILS_ENV` or `RACK_ENV` environment variables.
|
69
|
+
If set to `production`, defaults to `gateway.push.apple.com`, if set to `test`, defaults to `localhost` (see [Acceptance Testing](#acceptance-testing) later), otherwise defaults to `gateway.sandbox.push.apple.com`.
|
70
|
+
* `retries`: The number of times **grocer** will retry writing to or reading from the Apple Push Notification Service before raising any errors to client code.
|
79
71
|
|
80
72
|
### Sending Notifications
|
81
73
|
|
@@ -98,8 +90,7 @@ notification = Grocer::Notification.new(
|
|
98
90
|
pusher.push(notification) # return value is the number of bytes sent successfully
|
99
91
|
```
|
100
92
|
|
101
|
-
It is desirable to reuse the same connection to send multiple notifications, as
|
102
|
-
is recommended by Apple.
|
93
|
+
It is desirable to reuse the same connection to send multiple notifications, as is recommended by Apple.
|
103
94
|
|
104
95
|
```ruby
|
105
96
|
pusher = Grocer.pusher(connection_options)
|
@@ -110,9 +101,8 @@ end
|
|
110
101
|
|
111
102
|
#### Custom Payloads
|
112
103
|
|
113
|
-
The Apple documentation says "Providers can specify custom payload values
|
114
|
-
|
115
|
-
`Grocer::Notification#custom`.
|
104
|
+
The Apple documentation says "Providers can specify custom payload values outside the Apple-reserved aps namespace."
|
105
|
+
To specify a custom payload, set `Grocer::Notification#custom`.
|
116
106
|
|
117
107
|
```ruby
|
118
108
|
notification = Grocer::Notification.new(
|
@@ -129,10 +119,9 @@ notification = Grocer::Notification.new(
|
|
129
119
|
|
130
120
|
#### Passbook Notifications
|
131
121
|
|
132
|
-
A `Grocer::PassbookNotification` is a specialized kind of notification which
|
133
|
-
|
134
|
-
|
135
|
-
send any payload for a Passbook notification. If you do, it will be ignored.
|
122
|
+
A `Grocer::PassbookNotification` is a specialized kind of notification which does not require any payload.
|
123
|
+
That is, you need not (and *[Apple explicitly says not to](http://developer.apple.com/library/ios/#Documentation/UserExperience/Conceptual/PassKit_PG/Chapters/Updating.html#//apple_ref/doc/uid/TP40012195-CH5-SW1)*) send any payload for a Passbook notification.
|
124
|
+
If you do, it will be ignored.
|
136
125
|
|
137
126
|
```ruby
|
138
127
|
notification = Grocer::PassbookNotification.new(device_token: "...")
|
@@ -143,21 +132,19 @@ notification = Grocer::PassbookNotification.new(device_token: "...")
|
|
143
132
|
#### Newsstand Notifications
|
144
133
|
|
145
134
|
Grocer also supports the special Newsstand 'content-available' notification.
|
146
|
-
`Grocer::NewsstandNotification` can be used for this.
|
147
|
-
`Grocer::PassbookNotification`, it is a specialized kind of notification which
|
148
|
-
|
135
|
+
`Grocer::NewsstandNotification` can be used for this.
|
136
|
+
Like `Grocer::PassbookNotification`, it is a specialized kind of notification which does not require any payload.
|
137
|
+
Likewise, anything you add to it will be ignored.
|
149
138
|
|
150
139
|
```ruby
|
151
140
|
notification = Grocer::NewsstandNotification.new(device_token: "...")
|
152
141
|
# Generates a JSON payload like:
|
153
142
|
# {"aps": {"content-available":1}}
|
154
|
-
|
143
|
+
```
|
155
144
|
|
156
145
|
#### Safari Notifications
|
157
146
|
|
158
|
-
Grocer can be used for [Safari Push
|
159
|
-
Notifications](https://developer.apple.com/notifications/safari-push-notifications/)
|
160
|
-
introduced in Mavericks.
|
147
|
+
Grocer can be used for [Safari Push Notifications](https://developer.apple.com/notifications/safari-push-notifications/) introduced in Mavericks.
|
161
148
|
|
162
149
|
```ruby
|
163
150
|
notification = Grocer::SafariNotification.new(
|
@@ -204,26 +191,20 @@ end
|
|
204
191
|
|
205
192
|
#### Notes
|
206
193
|
|
207
|
-
* `gateway`: Defaults to `feedback.push.apple.com` **only** when running in a
|
208
|
-
|
209
|
-
|
210
|
-
sandbox gateway, `feedback.sandbox.push.apple.com`.
|
211
|
-
* `retries`: The number of times **grocer** will retry writing to or reading
|
212
|
-
from the Apple Push Notification Service before raising any errors to client
|
213
|
-
code.
|
194
|
+
* `gateway`: Defaults to `feedback.push.apple.com` **only** when running in a production environment, as determined by either the `RAILS_ENV` or `RACK_ENV` environment variables.
|
195
|
+
In all other cases, it defaults to the sandbox gateway, `feedback.sandbox.push.apple.com`.
|
196
|
+
* `retries`: The number of times **grocer** will retry writing to or reading from the Apple Push Notification Service before raising any errors to client code.
|
214
197
|
|
215
198
|
### Acceptance Testing
|
216
199
|
|
217
|
-
Grocer ships with framework to setup a real looking APNS server.
|
218
|
-
a real SSL-capable socket bound to localhost.
|
219
|
-
Notes](#notes) above for details.
|
200
|
+
Grocer ships with framework to setup a real looking APNS server.
|
201
|
+
It listens on a real SSL-capable socket bound to localhost.
|
202
|
+
See the [Connecting Notes](#notes) above for details.
|
220
203
|
|
221
|
-
You can setup an APNS client to talk to it, then inspect the notifications the
|
222
|
-
server received.
|
204
|
+
You can setup an APNS client to talk to it, then inspect the notifications the server received.
|
223
205
|
|
224
|
-
The server simply exposes a blocking queue where notifications are placed when
|
225
|
-
|
226
|
-
received in a reasonable amount of time.
|
206
|
+
The server simply exposes a blocking queue where notifications are placed when they are received.
|
207
|
+
It is your responsibility to timeout if a message is not received in a reasonable amount of time.
|
227
208
|
|
228
209
|
For example, in RSpec:
|
229
210
|
|
@@ -253,10 +234,8 @@ end
|
|
253
234
|
|
254
235
|
## Device Token
|
255
236
|
|
256
|
-
A device token is obtained from within the iOS app.
|
257
|
-
[Registering for Remote
|
258
|
-
Notifications](http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html#//apple_ref/doc/uid/TP40008194-CH103-SW1)
|
259
|
-
documentation.
|
237
|
+
A device token is obtained from within the iOS app.
|
238
|
+
More details are in Apple's [Registering for Remote Notifications](http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html#//apple_ref/doc/uid/TP40008194-CH103-SW1) documentation.
|
260
239
|
|
261
240
|
The key code for this purpose is:
|
262
241
|
|
@@ -279,37 +258,38 @@ The key code for this purpose is:
|
|
279
258
|
|
280
259
|
## Certificate File
|
281
260
|
|
282
|
-
Login to the [iOS Provisioning Portal (App IDs)](https://developer.apple.com/ios/
|
261
|
+
Login to the [iOS Provisioning Portal (App IDs)](https://developer.apple.com/account/ios/identifier/bundle).
|
262
|
+
|
263
|
+
Select your app bundle, scroll down and click "Edit."
|
264
|
+
This will bring you to a page that will allow you to setup and configure services for your app.
|
265
|
+
Scroll down until you see the service labeled "Push Notifications."
|
266
|
+
Depending on whether you’re creating a Development or Production certificate, click the appropriate "Create Certificate" button.
|
283
267
|
|
284
|
-
|
285
|
-
|
268
|
+
![Creating the Push Notification
|
269
|
+
Certificate](images/Creating_the_Push_Notification_Certificate.png)
|
286
270
|
|
287
|
-
|
288
|
-
Certificate](images/Downloading_the_Push_Notification_Certificate.png)
|
271
|
+
Follow the instructions to create a Certificate Signing Request, click "Continue," upload the CSR, and download the resulting `.cer` file.
|
289
272
|
|
290
|
-
Open the file in Keychain Access, then expand the certificate to show both the
|
291
|
-
|
273
|
+
Open the `.cer` file in Keychain Access, then expand the certificate to show both the certificate *and* the private key.
|
274
|
+
Command-select so both are highlighted:
|
292
275
|
|
293
|
-
![Selecting both the certificate and private
|
294
|
-
key](images/Selecting_both_the_certificate_and_private_key.png)
|
276
|
+
![Selecting both the certificate and private key](images/Selecting_both_the_certificate_and_private_key.png)
|
295
277
|
|
296
278
|
Control click and select to export the 2 items:
|
297
279
|
|
298
|
-
![Exporting the certificate and private
|
299
|
-
key](images/Exporting_the_certificate_and_private_key.png)
|
280
|
+
![Exporting the certificate and private key](images/Exporting_the_certificate_and_private_key.png)
|
300
281
|
|
301
|
-
Save the items as a `.p12` file.
|
302
|
-
command:
|
282
|
+
Save the items as a `.p12` file.
|
283
|
+
Open a terminal window and run the following command:
|
303
284
|
|
304
285
|
```bash
|
305
286
|
openssl pkcs12 -in exported_certificate.p12 -out certificate.pem -nodes -clcerts -des3
|
306
287
|
```
|
307
288
|
|
308
|
-
You will be prompted for two password.
|
309
|
-
that you used when you exported the private key and certificate from
|
310
|
-
|
311
|
-
|
312
|
-
**grocer** to connect to APNs.
|
289
|
+
You will be prompted for two password.
|
290
|
+
The first one is the password that you used when you exported the private key and certificate from Keychain Access.
|
291
|
+
The second password will be used to encrypt and lock the private key.
|
292
|
+
This will be the passphrase used when configuring **grocer** to connect to APNs.
|
313
293
|
|
314
294
|
The `certificate.pem` file that is generated can be used with **grocer**.
|
315
295
|
|
@@ -340,9 +320,6 @@ cat push.pem push_private_key.pem > certificate.pem
|
|
340
320
|
|
341
321
|
## Support Channels
|
342
322
|
|
343
|
-
[GitHub Issues](https://github.com/grocer/grocer/issues) and [Pull
|
344
|
-
|
345
|
-
|
346
|
-
regularly hang out in the `#grocer` channel on Freenode; feel free to pop in
|
347
|
-
and ask questions there as well. Thanks! :heart:
|
348
|
-
|
323
|
+
[GitHub Issues](https://github.com/grocer/grocer/issues) and [Pull Requests](https://github.com/grocer/grocer/pulls) are the primary venues for communicating issues and discussing possible features.
|
324
|
+
Several of us also regularly hang out in the `#grocer` channel on Freenode; feel free to pop in and ask questions there as well.
|
325
|
+
Thanks! :heart:
|
Binary file
|
@@ -6,7 +6,8 @@ module Grocer
|
|
6
6
|
result = {}
|
7
7
|
each do |key, value|
|
8
8
|
# Workaround for JRuby defining Fixnum#to_sym even in 1.9 mode
|
9
|
-
|
9
|
+
# (now updated to Integer, for Ruby >= 2.4.0)
|
10
|
+
symbolized_key = key.is_a?(Integer) ? key : (key.to_sym rescue key)
|
10
11
|
|
11
12
|
result[symbolized_key] = value.is_a?(Hash) ?
|
12
13
|
(value.extend DeepSymbolizeKeys).deep_symbolize_keys : value
|
data/lib/grocer/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grocer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Lindeman
|
@@ -10,84 +10,88 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2017-04-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- - ~>
|
19
|
+
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '3.4'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- - ~>
|
26
|
+
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '3.4'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: pry
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- - ~>
|
33
|
+
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
version: 0.10.1
|
36
36
|
type: :development
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- - ~>
|
40
|
+
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: 0.10.1
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: mocha
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- -
|
47
|
+
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: '0'
|
50
50
|
type: :development
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- -
|
54
|
+
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: '0'
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: bourne
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- -
|
61
|
+
- - ">="
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '0'
|
64
64
|
type: :development
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- -
|
68
|
+
- - ">="
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: rake
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - ">="
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
|
-
- -
|
82
|
+
- - ">="
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
|
-
description:
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
85
|
+
description: |2
|
86
|
+
Grocer interfaces with the Apple Push
|
87
|
+
Notification Service to send push
|
88
|
+
notifications to iOS devices and collect
|
89
|
+
notification feedback via the Feedback
|
90
|
+
Service.
|
91
|
+
|
92
|
+
There are other gems out there to do this,
|
93
|
+
but Grocer plans to be the cleanest, most
|
94
|
+
extensible, and friendliest.
|
91
95
|
email:
|
92
96
|
- alindeman@gmail.com
|
93
97
|
- steveharman@gmail.com
|
@@ -96,16 +100,16 @@ executables: []
|
|
96
100
|
extensions: []
|
97
101
|
extra_rdoc_files: []
|
98
102
|
files:
|
99
|
-
- .gitignore
|
100
|
-
- .rspec
|
101
|
-
- .travis.yml
|
103
|
+
- ".gitignore"
|
104
|
+
- ".rspec"
|
105
|
+
- ".travis.yml"
|
102
106
|
- CHANGELOG.md
|
103
107
|
- Gemfile
|
104
108
|
- LICENSE
|
105
109
|
- README.md
|
106
110
|
- Rakefile
|
107
111
|
- grocer.gemspec
|
108
|
-
- images/
|
112
|
+
- images/Creating_the_Push_Notification_Certificate.png
|
109
113
|
- images/Exporting_the_certificate_and_private_key.png
|
110
114
|
- images/Selecting_both_the_certificate_and_private_key.png
|
111
115
|
- lib/grocer.rb
|
@@ -164,17 +168,17 @@ require_paths:
|
|
164
168
|
- lib
|
165
169
|
required_ruby_version: !ruby/object:Gem::Requirement
|
166
170
|
requirements:
|
167
|
-
- -
|
171
|
+
- - ">="
|
168
172
|
- !ruby/object:Gem::Version
|
169
173
|
version: '0'
|
170
174
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
175
|
requirements:
|
172
|
-
- -
|
176
|
+
- - ">="
|
173
177
|
- !ruby/object:Gem::Version
|
174
178
|
version: '0'
|
175
179
|
requirements: []
|
176
180
|
rubyforge_project:
|
177
|
-
rubygems_version: 2.6.
|
181
|
+
rubygems_version: 2.6.8
|
178
182
|
signing_key:
|
179
183
|
specification_version: 4
|
180
184
|
summary: Pushing Apple notifications since 2012.
|
Binary file
|