Class: FiveMobilePush::Notifier
- Inherits:
-
Object
- Object
- FiveMobilePush::Notifier
- Defined in:
- lib/five_mobile_push/notifier.rb,
lib/five_mobile_push/message.rb
Overview
TODO:
Validate provided platforms
Defined Under Namespace
Classes: Message
Instance Method Summary collapse
-
#broadcast(platforms) {|message| ... } ⇒ Object
Broadcast a notification to one or more platforms of an application.
-
#initialize(client) ⇒ Notifier
constructor
A new instance of Notifier.
-
#notify_by_tags(platforms, tags) {|message| ... } ⇒ Object
Notifies any device registered with the provided tags.
-
#notify_devices(devices) {|message| ... } ⇒ Object
Send a notification to any number of specified devices.
Constructor Details
#initialize(client) ⇒ Notifier
Returns a new instance of Notifier.
6 7 8 |
# File 'lib/five_mobile_push/notifier.rb', line 6 def initialize(client) @client = client end |
Instance Method Details
#broadcast(platforms) {|message| ... } ⇒ Object
Broadcast a notification to one or more platforms of an application.
26 27 28 29 30 |
# File 'lib/five_mobile_push/notifier.rb', line 26 def broadcast(platforms, &block) @client.post 'notify/broadcast', :platforms => Platform.new(platforms).build_list, :payload => Message.dsl(&block).to_json end |
#notify_by_tags(platforms, tags) {|message| ... } ⇒ Object
Notifies any device registered with the provided tags.
70 71 72 73 74 75 |
# File 'lib/five_mobile_push/notifier.rb', line 70 def (platforms, , &block) @client.post 'notify/toTags', :platforms => Platform.new(platforms).build_list, :tags => .join(','), :payload => Message.dsl(&block).to_json end |
#notify_devices(devices) {|message| ... } ⇒ Object
Send a notification to any number of specified devices
46 47 48 49 50 51 |
# File 'lib/five_mobile_push/notifier.rb', line 46 def notify_devices(devices, &block) @client.post 'notify/toDevices', :id_type => FiveMobilePush::DEFAULT_ID_TYPE, :id_values => devices.join(','), :payload => Message.dsl(&block).to_json end |