Class: Ably::Realtime::Push::Admin
- Inherits:
-
Object
- Object
- Ably::Realtime::Push::Admin
- Includes:
- Modules::AsyncWrapper, Modules::Conversions
- Defined in:
- lib/ably/realtime/push/admin.rb
Overview
Class providing push notification administrative functionality for registering devices and attaching to channels etc.
Instance Attribute Summary collapse
- #client ⇒ Object readonly private
- #push ⇒ Object readonly private
Instance Method Summary collapse
-
#channel_subscriptions ⇒ Ably::Realtime::Push::ChannelSubscriptions
A ChannelSubscriptions object.
-
#device_registrations ⇒ Ably::Realtime::Push::DeviceRegistrations
A DeviceRegistrations object.
-
#initialize(push) ⇒ Admin
constructor
A new instance of Admin.
-
#publish(recipient, data) { ... } ⇒ Ably::Util::SafeDeferrable
Sends a push notification directly to a device, or a group of devices sharing the same clientId.
Constructor Details
#initialize(push) ⇒ Admin
Returns a new instance of Admin.
19 20 21 22 |
# File 'lib/ably/realtime/push/admin.rb', line 19 def initialize(push) @push = push @client = push.client end |
Instance Attribute Details
#client ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 |
# File 'lib/ably/realtime/push/admin.rb', line 14 def client @client end |
#push ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 |
# File 'lib/ably/realtime/push/admin.rb', line 17 def push @push end |
Instance Method Details
#channel_subscriptions ⇒ Ably::Realtime::Push::ChannelSubscriptions
A ChannelSubscriptions object.
61 62 63 |
# File 'lib/ably/realtime/push/admin.rb', line 61 def channel_subscriptions @channel_subscriptions ||= ChannelSubscriptions.new(self) end |
#device_registrations ⇒ Ably::Realtime::Push::DeviceRegistrations
A DeviceRegistrations object.
51 52 53 |
# File 'lib/ably/realtime/push/admin.rb', line 51 def device_registrations @device_registrations ||= DeviceRegistrations.new(self) end |
#publish(recipient, data) { ... } ⇒ Ably::Util::SafeDeferrable
Sends a push notification directly to a device, or a group of devices sharing the same clientId.
(see Ably::Rest::Push#publish)
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ably/realtime/push/admin.rb', line 34 def publish(recipient, data, &callback) raise ArgumentError, "Expecting a Hash object for recipient, got #{recipient.class}" unless recipient.kind_of?(Hash) raise ArgumentError, "Recipient data is empty. You must provide recipient details" if recipient.empty? raise ArgumentError, "Expecting a Hash object for data, got #{data.class}" unless data.kind_of?(Hash) raise ArgumentError, "Push data field is empty. You must provide attributes for the push notification" if data.empty? async_wrap(callback) do rest_push_admin.publish(recipient, data) end end |