Skip to content

Commit

Permalink
Merge pull request #221 from aried3r/ar/content_available_gcm
Browse files Browse the repository at this point in the history
Add content_available to GCM notifications
  • Loading branch information
ileitch committed Jan 22, 2016
2 parents dcad678 + c58135a commit 1602529
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
rpush (2.5.0)
rpush (2.6.0)
activesupport
ansi
multi_json (~> 1.0)
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.rails-3.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
rpush (2.5.0)
rpush (2.6.0)
activesupport
ansi
multi_json (~> 1.0)
Expand Down
1 change: 1 addition & 0 deletions lib/generators/rpush_migration_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def copy_migration

add_rpush_migration('rpush_2_0_0_updates')
add_rpush_migration('rpush_2_1_0_updates')
add_rpush_migration('rpush_2_6_0_updates')
end

protected
Expand Down
10 changes: 10 additions & 0 deletions lib/generators/templates/rpush_2_6_0_updates.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Rpush260Updates < ActiveRecord::Migration
def self.up
add_column :rpush_notifications, :content_available, :boolean, default: false
end

def self.down
remove_column :rpush_notifications, :content_available
end
end

1 change: 1 addition & 0 deletions lib/rpush/client/active_model/gcm/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def as_json
}
json['collapse_key'] = collapse_key if collapse_key
json['time_to_live'] = expiry if expiry
json['content_available'] = content_available if content_available
json
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rpush/client/active_record/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Notification < ::ActiveRecord::Base
attr_accessible :badge, :device_token, :sound, :alert, :data, :expiry, :delivered,
:delivered_at, :failed, :failed_at, :error_code, :error_description, :deliver_after,
:alert_is_json, :app, :app_id, :collapse_key, :delay_while_idle, :registration_ids,
:uri, :url_args, :category
:uri, :url_args, :category, :content_available
end

def data=(attrs)
Expand Down
1 change: 1 addition & 0 deletions lib/rpush/client/mongoid/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Notification
field :priority, type: Integer
field :url_args, type: Array
field :category, type: String
field :content_available, type: Boolean, default: false

field :integer_id, type: Integer
increments :integer_id, model_name: name
Expand Down
1 change: 1 addition & 0 deletions lib/rpush/client/redis/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def self.absolute_retryable_namespace
attribute :priority, :integer
attribute :url_args, :array
attribute :category, :string
attribute :content_available, :boolean, default: false

def app
return nil unless app_id
Expand Down
2 changes: 1 addition & 1 deletion lib/rpush/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Rpush
VERSION = '2.5.0'
VERSION = '2.6.0'
end
3 changes: 2 additions & 1 deletion spec/support/active_record_setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
require 'generators/templates/add_rpush'
require 'generators/templates/rpush_2_0_0_updates'
require 'generators/templates/rpush_2_1_0_updates'
require 'generators/templates/rpush_2_6_0_updates'

migrations = [AddRpush, Rpush200Updates, Rpush210Updates]
migrations = [AddRpush, Rpush200Updates, Rpush210Updates, Rpush260Updates]

unless ENV['TRAVIS']
migrations.reverse_each do |m|
Expand Down
5 changes: 5 additions & 0 deletions spec/unit/client/active_record/gcm/notification_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@
notification.expiry = 100
expect(notification.as_json['time_to_live']).to eq 100
end

it 'includes content_available in the payload' do
notification.content_available = true
expect(notification.as_json['content_available']).to eq true
end
end if active_record?

0 comments on commit 1602529

Please sign in to comment.