rpush 2.4.0-java → 2.6.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -1
  3. data/README.md +18 -8
  4. data/lib/generators/rpush_migration_generator.rb +1 -0
  5. data/lib/generators/templates/rpush.rb +8 -2
  6. data/lib/generators/templates/rpush_2_0_0_updates.rb +1 -1
  7. data/lib/generators/templates/rpush_2_6_0_updates.rb +10 -0
  8. data/lib/rpush/cli.rb +63 -27
  9. data/lib/rpush/client/active_model.rb +3 -0
  10. data/lib/rpush/client/active_model/apns/notification.rb +1 -1
  11. data/lib/rpush/client/active_model/gcm/notification.rb +1 -0
  12. data/lib/rpush/client/active_model/wns/app.rb +23 -0
  13. data/lib/rpush/client/active_model/wns/notification.rb +28 -0
  14. data/lib/rpush/client/active_model/wpns/notification.rb +11 -6
  15. data/lib/rpush/client/active_record.rb +3 -0
  16. data/lib/rpush/client/active_record/notification.rb +1 -1
  17. data/lib/rpush/client/active_record/wns/app.rb +11 -0
  18. data/lib/rpush/client/active_record/wns/notification.rb +11 -0
  19. data/lib/rpush/client/mongoid.rb +3 -0
  20. data/lib/rpush/client/mongoid/apns/feedback.rb +3 -0
  21. data/lib/rpush/client/mongoid/notification.rb +7 -0
  22. data/lib/rpush/client/mongoid/wns/app.rb +14 -0
  23. data/lib/rpush/client/mongoid/wns/notification.rb +11 -0
  24. data/lib/rpush/client/redis.rb +3 -0
  25. data/lib/rpush/client/redis/notification.rb +1 -0
  26. data/lib/rpush/client/redis/wns/app.rb +14 -0
  27. data/lib/rpush/client/redis/wns/notification.rb +11 -0
  28. data/lib/rpush/configuration.rb +3 -7
  29. data/lib/rpush/daemon.rb +9 -0
  30. data/lib/rpush/daemon/apns/feedback_receiver.rb +5 -0
  31. data/lib/rpush/daemon/app_runner.rb +4 -5
  32. data/lib/rpush/daemon/dispatcher/apns_tcp.rb +47 -12
  33. data/lib/rpush/daemon/dispatcher_loop.rb +5 -0
  34. data/lib/rpush/daemon/feeder.rb +11 -0
  35. data/lib/rpush/daemon/gcm/delivery.rb +2 -2
  36. data/lib/rpush/daemon/interruptible_sleep.rb +8 -3
  37. data/lib/rpush/daemon/loggable.rb +4 -0
  38. data/lib/rpush/daemon/rpc.rb +9 -0
  39. data/lib/rpush/daemon/rpc/client.rb +27 -0
  40. data/lib/rpush/daemon/rpc/server.rb +82 -0
  41. data/lib/rpush/daemon/signal_handler.rb +7 -0
  42. data/lib/rpush/daemon/store/active_record.rb +17 -3
  43. data/lib/rpush/daemon/store/mongoid.rb +2 -2
  44. data/lib/rpush/daemon/store/redis.rb +2 -2
  45. data/lib/rpush/daemon/tcp_connection.rb +2 -2
  46. data/lib/rpush/daemon/wns.rb +9 -0
  47. data/lib/rpush/daemon/wns/delivery.rb +204 -0
  48. data/lib/rpush/embed.rb +15 -13
  49. data/lib/rpush/logger.rb +4 -0
  50. data/lib/rpush/plugin.rb +1 -1
  51. data/lib/rpush/push.rb +2 -11
  52. data/lib/rpush/reflection_collection.rb +15 -17
  53. data/lib/rpush/reflection_public_methods.rb +6 -4
  54. data/lib/rpush/version.rb +1 -1
  55. data/spec/functional/apns_spec.rb +1 -11
  56. data/spec/functional/cli_spec.rb +36 -0
  57. data/spec/functional_spec_helper.rb +11 -1
  58. data/spec/spec_helper.rb +4 -3
  59. data/spec/support/active_record_setup.rb +3 -2
  60. data/spec/unit/client/active_record/apns/notification_spec.rb +1 -1
  61. data/spec/unit/client/active_record/gcm/notification_spec.rb +5 -0
  62. data/spec/unit/configuration_spec.rb +0 -7
  63. data/spec/unit/daemon/adm/delivery_spec.rb +2 -2
  64. data/spec/unit/daemon/app_runner_spec.rb +2 -3
  65. data/spec/unit/daemon/gcm/delivery_spec.rb +1 -1
  66. data/spec/unit/daemon/tcp_connection_spec.rb +1 -1
  67. data/spec/unit/daemon/wns/delivery_spec.rb +171 -0
  68. data/spec/unit/daemon/wpns/delivery_spec.rb +1 -1
  69. data/spec/unit/daemon_spec.rb +2 -0
  70. data/spec/unit/embed_spec.rb +4 -11
  71. data/spec/unit/logger_spec.rb +2 -2
  72. data/spec/unit/push_spec.rb +0 -7
  73. data/spec/unit_spec_helper.rb +1 -1
  74. metadata +20 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 49a209aeb1cf3b46511c9376fb0f35ba4ca1398e
4
- data.tar.gz: c1402f1adf30cbb8c3fa2a81f1851920d0b4271d
3
+ metadata.gz: e36b7827149618d0b74c67c02e6ea6d99f4086b8
4
+ data.tar.gz: 1374ea61141d5338fe9b2de73afb1aaf8b2f28ba
5
5
  SHA512:
6
- metadata.gz: ecea38aeb595d81a6b45ca2c83a9c4e45592e3fdc03022872948892153db560ac0719134d51823b188d1cde2e7f39709706497f3af37b30499b73acf5c176c58
7
- data.tar.gz: 80229d942221cd34f38ae7a8a9684b102e7954cfb0201b7dd5eb63bfbdd9d6f05a4f87e0413b7fd857254fbc44df17ec5ed84d9a56d28622fc98f69c6a776f8f
6
+ metadata.gz: fb3b91e3cd8b7a858545ad55f7f89c007fa9f2c9c8d346c0033d6197f7bf32976f017b5ec2818e5b47bd0d8ecdceb1cc28b41ef71222b841af58fa29f553c1c6
7
+ data.tar.gz: 68d2cc0d984006bada00d204b9f0721f2048aaa80ca0ea00e38b24b0d41fe2a5bdb8dbd3341acd05617dd70254b2c6e9e974d908e8ec89d7197bdad08b3d5302
@@ -1,4 +1,30 @@
1
- ## 2.4.0 (Fed 18, 2015)
1
+ ## 2.6.0 (Jan 25, 2016)
2
+
3
+ #### Features
4
+
5
+ * Added support for GCM for iOS' `content_available`. ([#221](https://github.com/rpush/rpush/pull/221))
6
+
7
+ #### Fixes
8
+
9
+ * Fix typo in Oracle support. ([#185](https://github.com/rpush/rpush/pull/185))
10
+ * Remove `param` tag from WNS message. ([#190](https://github.com/rpush/rpush/pull/190))
11
+ * Fixed WNS response headers parser. ([#192](https://github.com/rpush/rpush/pull/192))
12
+ * GCM: fixed raise of unhandled errors. ([#193](https://github.com/rpush/rpush/pull/193))
13
+ * Fix issue with custom PID file set in `Rpush.config`. ([#224](https://github.com/rpush/rpush/pull/224), [#225](https://github.com/rpush/rpush/pull/225))
14
+
15
+ ## 2.5.0 (July 19, 2015)
16
+ Features:
17
+ * Add 'rpush status' to inspect running Rpush internal status.
18
+ * ActiveRecord logging is no longer redirected to rpush.log when embedded (#138).
19
+ * Support for WNS (Windows RT) (#137).
20
+ * Indexes added to some Mongoid fields (#151).
21
+ * Added support for Oracle.
22
+
23
+ Bug fixes:
24
+ * Fix for handling APNs error when using `rpush push` or `Rpush.push`.
25
+ * Fix backwards compatibility issue with ActiveRecord (#144).
26
+
27
+ ## 2.4.0 (Feb 18, 2015)
2
28
  Features:
3
29
  * Support for MongoDB (using Mongoid).
4
30
  * config.feedback_poll is now deprecated, use config.apns.feedback_receiver.frequency instead.
data/README.md CHANGED
@@ -1,7 +1,5 @@
1
- [![Build Status](https://secure.travis-ci.org/rpush/rpush.svg?branch=master)](http://travis-ci.org/rpush/rpush)
2
- [![Code Climate](https://codeclimate.com/github/rpush/rpush/badges/gpa.svg)](https://codeclimate.com/github/rpush/rpush)
3
- [![Test Coverage](https://codeclimate.com/github/rpush/rpush/badges/coverage.svg)](https://codeclimate.com/github/rpush/rpush)
4
1
  [![Gem Version](https://badge.fury.io/rb/rpush.svg)](http://badge.fury.io/rb/rpush)
2
+ [![Join the chat at https://gitter.im/rpush/rpush](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/rpush/rpush?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5
3
 
6
4
  <img src="https://raw.github.com/rpush/rpush/master/logo.png" align="right" width="200px" />
7
5
 
@@ -21,9 +19,9 @@ Rpush aims to be the *de facto* gem for sending push notifications in Ruby. Its
21
19
 
22
20
  * Use [**ActiveRecord**](https://github.com/rpush/rpush/wiki/Using-ActiveRecord), [**Redis**](https://github.com/rpush/rpush/wiki/Using-Redis) or [**MongoDB**](https://github.com/rpush/rpush/wiki/Using-Mongodb) for storage.
23
21
  * Plugins for [**Bugsnag**](https://github.com/rpush/rpush-plugin-bugsnag),
24
- [**Sentry**](https://github.com/rpush/rpush-plugin-sentry), [**StatsD**](https://github.com/rpush/rpush-plugin-statsd).
22
+ [**Sentry**](https://github.com/rpush/rpush-plugin-sentry), [**StatsD**](https://github.com/rpush/rpush-plugin-statsd) or [write your own](https://github.com/rpush/rpush/wiki/Writing-a-Plugin).
25
23
  * Seamless integration with your projects, including **Rails**.
26
- * Run as a [daemon](https://github.com/rpush/rpush#as-a-daemon-recommended), inside a [job queue](https://github.com/rpush/rpush/wiki/Push-API), on the [command-line](https://github.com/rpush/rpush#on-the-command-line) or [embedded](https://github.com/rpush/rpush/wiki/Embedding-API) in another process.
24
+ * Run as a [daemon](https://github.com/rpush/rpush#as-a-daemon), inside a [job queue](https://github.com/rpush/rpush/wiki/Push-API), on the [command-line](https://github.com/rpush/rpush#on-the-command-line) or [embedded](https://github.com/rpush/rpush/wiki/Embedding-API) in another process.
27
25
  * Scales vertically (threading) and horizontally (multiple processes).
28
26
  * Designed for uptime - new apps are loaded automatically, signal `HUP` to update running apps.
29
27
  * Hooks for fine-grained instrumentation and error handling ([Reflection API](https://github.com/rpush/rpush/wiki/Reflection-API)).
@@ -87,7 +85,7 @@ app.save!
87
85
  ```ruby
88
86
  n = Rpush::Gcm::Notification.new
89
87
  n.app = Rpush::Gcm::App.find_by_name("android_app")
90
- n.registration_ids = ["token", "..."]
88
+ n.registration_ids = ["..."]
91
89
  n.data = { message: "hi mom!" }
92
90
  n.save!
93
91
  ```
@@ -121,6 +119,8 @@ For more documentation on [ADM](https://developer.amazon.com/sdk/adm.html).
121
119
  ```ruby
122
120
  app = Rpush::Wpns::App.new
123
121
  app.name = "windows_phone_app"
122
+ app.client_id = # Get this from your apps dashboard https://dev.windows.com
123
+ app.client_secret = # Get this from your apps dashboard https://dev.windows.com
124
124
  app.connections = 1
125
125
  app.save!
126
126
  ```
@@ -177,6 +177,10 @@ end
177
177
 
178
178
  Call this during startup of your application, for example, by adding it to the end of `config/rpush.rb`. See [Embedding API](https://github.com/rpush/rpush/wiki/Embedding-API) for more details.
179
179
 
180
+ #### Using mina
181
+
182
+ If you're using [mina](https://github.com/mina-deploy/mina), there is a gem called [mina-rpush](https://github.com/d4rky-pl/mina-rpush) which helps you control rpush.
183
+
180
184
  ### Configuration
181
185
 
182
186
  See [Configuration](https://github.com/rpush/rpush/wiki/Configuration) for a list of options.
@@ -198,6 +202,7 @@ You should run `rpush init` after upgrading Rpush to check for configuration and
198
202
  * [Reflection API](https://github.com/rpush/rpush/wiki/Reflection-API)
199
203
  * [Push API](https://github.com/rpush/rpush/wiki/Push-API)
200
204
  * [Embedding API](https://github.com/rpush/rpush/wiki/Embedding-API)
205
+ * [Writing a Plugin](https://github.com/rpush/rpush/wiki/Writing-a-Plugin)
201
206
  * [Implementing your own storage backend](https://github.com/rpush/rpush/wiki/Implementing-your-own-storage-backend)
202
207
  * [Upgrading from 2.x to 3.0](https://github.com/rpush/rpush/wiki/Upgrading-from-version-2.x-to-3.0)
203
208
 
@@ -217,10 +222,15 @@ You should run `rpush init` after upgrading Rpush to check for configuration and
217
222
 
218
223
  When running specs, please note that the ActiveRecord adapter can be changed by setting the `ADAPTER` environment variable. For example: `ADAPTER=postgresql rake`.
219
224
 
220
- Available adapters for testing are `mysql`, `mysql2` and `postgresql`.
225
+ Available adapters for testing are `postgresql`, `jdbcpostgresql`, `mysql2`, `jdbcmysql`, `jdbch2`, and `sqlite3`.
221
226
 
222
227
  Note that the database username is changed at runtime to be the currently logged in user's name. So if you're testing
223
228
  with mysql and you're using a user named 'bob', you will need to grant a mysql user 'bob' access to the 'rpush_test'
224
229
  mysql database.
225
230
 
226
- To switch between ActiveRecord and Redis, set the `CLIENT` environment variable to either `:active_record` or `:redis`.
231
+ To switch between ActiveRecord and Redis, set the `CLIENT` environment variable to either `active_record`, `redis` or `mongoid`.
232
+
233
+
234
+ [![Build Status](https://secure.travis-ci.org/rpush/rpush.svg?branch=master)](http://travis-ci.org/rpush/rpush)
235
+ [![Test Coverage](https://codeclimate.com/github/rpush/rpush/badges/coverage.svg)](https://codeclimate.com/github/rpush/rpush)
236
+ [![Code Climate](https://codeclimate.com/github/rpush/rpush/badges/gpa.svg)](https://codeclimate.com/github/rpush/rpush)
@@ -40,6 +40,7 @@ class RpushMigrationGenerator < Rails::Generators::Base
40
40
 
41
41
  add_rpush_migration('rpush_2_0_0_updates')
42
42
  add_rpush_migration('rpush_2_1_0_updates')
43
+ add_rpush_migration('rpush_2_6_0_updates')
43
44
  end
44
45
 
45
46
  protected
@@ -21,7 +21,7 @@ Rpush.configure do |config|
21
21
  # Path to log file. Relative to current directory unless absolute.
22
22
  config.log_file = 'log/rpush.log'
23
23
 
24
- config.log_level = (defined?(Rails) && Rails.logger) ? Rails.logger.level : ::Logger::Severity::DEBUG
24
+ config.log_level = (defined?(Rails) && Rails.logger) ? Rails.logger.level : ::Logger::Severity::INFO
25
25
 
26
26
  # Define a custom logger.
27
27
  # config.logger = MyLogger.new
@@ -29,7 +29,7 @@ Rpush.configure do |config|
29
29
  # config.apns.feedback_receiver.enabled = true
30
30
  # config.apns.feedback_receiver.frequency = 60
31
31
 
32
- end
32
+ end
33
33
 
34
34
  Rpush.reflect do |on|
35
35
 
@@ -123,6 +123,12 @@ Rpush.reflect do |on|
123
123
  # on.adm_failed_to_recipient do |notification, registration_id, reason|
124
124
  # end
125
125
 
126
+ # Called when Failed to deliver to WNS. Check the 'reason' string for further
127
+ # explanations.
128
+ # You should remove this uri from your records
129
+ # on.wns_invalid_channel do |notification, uri, reason|
130
+ # end
131
+
126
132
  # Called when an exception is raised.
127
133
  # on.error do |error|
128
134
  # end
@@ -58,7 +58,7 @@ class Rpush200Updates < ActiveRecord::Migration
58
58
 
59
59
  def self.adapter_name
60
60
  env = (defined?(Rails) && Rails.env) ? Rails.env : 'development'
61
- ActiveRecord::Base.configurations[env]['adapter']
61
+ Hash[ActiveRecord::Base.configurations[env].map { |k,v| [k.to_sym,v] }][:adapter]
62
62
  end
63
63
 
64
64
  def self.postgresql?
@@ -0,0 +1,10 @@
1
+ class Rpush260Updates < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :rpush_notifications, :content_available, :boolean, default: false
4
+ end
5
+
6
+ def self.down
7
+ remove_column :rpush_notifications, :content_available
8
+ end
9
+ end
10
+
@@ -30,28 +30,23 @@ module Rpush
30
30
  option 'pid-file', type: :string, aliases: '-p'
31
31
  def stop
32
32
  config_setup
33
- ensure_pid_file_set
34
-
35
- if File.exist?(Rpush.config.pid_file)
36
- pid = File.read(Rpush.config.pid_file).strip.to_i
37
- STDOUT.write "* Stopping Rpush (pid #{pid})... "
38
- STDOUT.flush
39
- Process.kill('TERM', pid)
40
-
41
- loop do
42
- begin
43
- Process.getpgid(pid)
44
- sleep 0.05
45
- rescue Errno::ESRCH
46
- break
47
- end
33
+ pid = rpush_process_pid
34
+ return unless pid
35
+
36
+ STDOUT.write "* Stopping Rpush (pid #{pid})... "
37
+ STDOUT.flush
38
+ Process.kill('TERM', pid)
39
+
40
+ loop do
41
+ begin
42
+ Process.getpgid(pid)
43
+ sleep 0.05
44
+ rescue Errno::ESRCH
45
+ break
48
46
  end
49
-
50
- puts ANSI.green { '✔' }
51
- else
52
- STDERR.puts("* Rpush isn't running? #{Rpush.config.pid_file} does not exist.")
53
- return
54
47
  end
48
+
49
+ puts ANSI.green { '✔' }
55
50
  end
56
51
 
57
52
  desc 'init', 'Initialize Rpush into the current directory'
@@ -96,6 +91,17 @@ module Rpush
96
91
  Rpush.push
97
92
  end
98
93
 
94
+ desc 'status', 'Show the internal status of the running Rpush instance.'
95
+ def status
96
+ config_setup
97
+
98
+ require 'rpush/daemon'
99
+ rpc = Rpush::Daemon::Rpc::Client.new(rpush_process_pid)
100
+ status = rpc.status
101
+ rpc.close
102
+ puts humanize_json(status)
103
+ end
104
+
99
105
  desc 'version', 'Print Rpush version'
100
106
  def version
101
107
  puts Rpush::VERSION
@@ -146,13 +152,6 @@ module Rpush
146
152
  self.class.default_config_path
147
153
  end
148
154
 
149
- def ensure_pid_file_set
150
- return unless Rpush.config.pid_file.blank?
151
-
152
- STDERR.puts(ANSI.red { 'ERROR: ' } + 'config.pid_file is not set.')
153
- exit 1
154
- end
155
-
156
155
  def check_ruby_version
157
156
  STDERR.puts(ANSI.yellow { 'WARNING: ' } + "You are using an old and unsupported version of Ruby.") if RUBY_VERSION <= '1.9.3' && RUBY_ENGINE == 'ruby'
158
157
  end
@@ -173,5 +172,42 @@ module Rpush
173
172
  new_options.freeze
174
173
  self.options = new_options
175
174
  end
175
+
176
+ def rpush_process_pid
177
+ if Rpush.config.pid_file.blank?
178
+ STDERR.puts(ANSI.red { 'ERROR: ' } + 'config.pid_file is not set.')
179
+ exit 1
180
+ end
181
+
182
+ unless File.exist?(Rpush.config.pid_file)
183
+ STDERR.puts("* Rpush isn't running? #{Rpush.config.pid_file} does not exist.")
184
+ exit 1
185
+ end
186
+
187
+ File.read(Rpush.config.pid_file).strip.to_i
188
+ end
189
+
190
+ def humanize_json(node, str = '', depth = 0) # rubocop:disable Metrics/PerceivedComplexity
191
+ if node.is_a?(Hash)
192
+ node = node.sort_by { |_, v| [Array, Hash].include?(v.class) ? 1 : 0 }
193
+ node.each do |k, v|
194
+ if [Array, Hash].include?(v.class)
195
+ str << "\n#{' ' * depth}#{k}:\n"
196
+ humanize_json(v, str, depth + 1)
197
+ else
198
+ str << "#{' ' * depth}#{k}: #{v}\n"
199
+ end
200
+ end
201
+ elsif node.is_a?(Array)
202
+ node.each do |v|
203
+ str << "\n" if v.is_a?(Hash)
204
+ humanize_json(v, str, depth)
205
+ end
206
+ else
207
+ str << "#{' ' * depth}#{node}\n"
208
+ end
209
+
210
+ str
211
+ end
176
212
  end
177
213
  end
@@ -19,3 +19,6 @@ require 'rpush/client/active_model/gcm/notification'
19
19
 
20
20
  require 'rpush/client/active_model/wpns/app'
21
21
  require 'rpush/client/active_model/wpns/notification'
22
+
23
+ require 'rpush/client/active_model/wns/app'
24
+ require 'rpush/client/active_model/wns/notification'
@@ -64,7 +64,7 @@ module Rpush
64
64
  json
65
65
  end
66
66
 
67
- def to_binary(options = {}) # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
67
+ def to_binary(options = {})
68
68
  frame_payload = payload
69
69
  frame_id = options[:for_validation] ? 0 : send(options.fetch(:id_attribute, :id))
70
70
  frame = ""
@@ -22,6 +22,7 @@ module Rpush
22
22
  }
23
23
  json['collapse_key'] = collapse_key if collapse_key
24
24
  json['time_to_live'] = expiry if expiry
25
+ json['content_available'] = content_available if content_available
25
26
  json
26
27
  end
27
28
  end
@@ -0,0 +1,23 @@
1
+ module Rpush
2
+ module Client
3
+ module ActiveModel
4
+ module Wns
5
+ module App
6
+ def self.included(base)
7
+ base.instance_eval do
8
+ validates :client_id, :client_secret, presence: true
9
+ end
10
+ end
11
+
12
+ def access_token_expired?
13
+ access_token_expiration.nil? || access_token_expiration < Time.now
14
+ end
15
+
16
+ def service_name
17
+ 'wns'
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,28 @@
1
+ module Rpush
2
+ module Client
3
+ module ActiveModel
4
+ module Wns
5
+ module Notification
6
+ module InstanceMethods
7
+ def alert=(value)
8
+ return unless value
9
+ data = self.data || {}
10
+ data['title'] = value
11
+ self.data = data
12
+ end
13
+ end
14
+
15
+ def self.included(base)
16
+ base.instance_eval do
17
+ include InstanceMethods
18
+
19
+ validates :uri, presence: true
20
+ validates :uri, format: { with: %r{https?://[\S]+} }
21
+ validates :data, presence: true
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -3,12 +3,7 @@ module Rpush
3
3
  module ActiveModel
4
4
  module Wpns
5
5
  module Notification
6
- def self.included(base)
7
- base.instance_eval do
8
- validates :uri, presence: true
9
- validates :uri, format: { with: %r{https?://[\S]+} }
10
- validates :data, presence: true
11
- end
6
+ module InstanceMethods
12
7
  def alert=(value)
13
8
  return unless value
14
9
  data = self.data || {}
@@ -16,6 +11,16 @@ module Rpush
16
11
  self.data = data
17
12
  end
18
13
  end
14
+
15
+ def self.included(base)
16
+ base.instance_eval do
17
+ include InstanceMethods
18
+
19
+ validates :uri, presence: true
20
+ validates :uri, format: { with: %r{https?://[\S]+} }
21
+ validates :data, presence: true
22
+ end
23
+ end
19
24
  end
20
25
  end
21
26
  end
@@ -15,5 +15,8 @@ require 'rpush/client/active_record/gcm/app'
15
15
  require 'rpush/client/active_record/wpns/notification'
16
16
  require 'rpush/client/active_record/wpns/app'
17
17
 
18
+ require 'rpush/client/active_record/wns/notification'
19
+ require 'rpush/client/active_record/wns/app'
20
+
18
21
  require 'rpush/client/active_record/adm/notification'
19
22
  require 'rpush/client/active_record/adm/app'
@@ -16,7 +16,7 @@ module Rpush
16
16
  attr_accessible :badge, :device_token, :sound, :alert, :data, :expiry, :delivered,
17
17
  :delivered_at, :failed, :failed_at, :error_code, :error_description, :deliver_after,
18
18
  :alert_is_json, :app, :app_id, :collapse_key, :delay_while_idle, :registration_ids,
19
- :uri, :url_args, :category
19
+ :uri, :url_args, :category, :content_available
20
20
  end
21
21
 
22
22
  def data=(attrs)
@@ -0,0 +1,11 @@
1
+ module Rpush
2
+ module Client
3
+ module ActiveRecord
4
+ module Wns
5
+ class App < Rpush::Client::ActiveRecord::App
6
+ include Rpush::Client::ActiveModel::Wns::App
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Rpush
2
+ module Client
3
+ module ActiveRecord
4
+ module Wns
5
+ class Notification < Rpush::Client::ActiveRecord::Notification
6
+ include Rpush::Client::ActiveModel::Wns::Notification
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end