class Ably::Realtime::Push::Admin
Class providing push notification administrative functionality for registering devices and attaching to channels etc.
Attributes
@api private
@api private
Public Class Methods
Source
# File lib/ably/realtime/push/admin.rb, line 19 def initialize(push) @push = push @client = push.client end
Public Instance Methods
Source
# File lib/ably/realtime/push/admin.rb, line 61 def channel_subscriptions @channel_subscriptions ||= ChannelSubscriptions.new(self) end
A {Ably::Realtime::Push::ChannelSubscriptions} object.
@spec RSH1c
@return [Ably::Realtime::Push::ChannelSubscriptions]
Source
# File lib/ably/realtime/push/admin.rb, line 51 def device_registrations @device_registrations ||= DeviceRegistrations.new(self) end
A {Ably::Realtime::Push::DeviceRegistrations} object.
@spec RSH1b
@return [Ably::Realtime::Push::DeviceRegistrations]
Source
# 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
Sends a push notification directly to a device, or a group of devices sharing the same clientId.
(see Ably::Rest::Push#publish)
@spec RSH1a
@yield Block is invoked upon successful publish of the message
@return [Ably::Util::SafeDeferrable]
Private Instance Methods
Source
# File lib/ably/realtime/push/admin.rb, line 66 def rest_push_admin client.rest_client.push.admin end