class Ably::Realtime::Push::Admin

Class providing push notification administrative functionality for registering devices and attaching to channels etc.

Attributes

client[R]

@api private

push[R]

@api private

Public Class Methods

new(push) click to toggle source
# File lib/submodules/ably-ruby/lib/ably/realtime/push/admin.rb, line 19
def initialize(push)
  @push = push
  @client = push.client
end

Public Instance Methods

channel_subscriptions() click to toggle source

A {Ably::Realtime::Push::ChannelSubscriptions} object.

@spec RSH1c

@return [Ably::Realtime::Push::ChannelSubscriptions]

# File lib/submodules/ably-ruby/lib/ably/realtime/push/admin.rb, line 61
def channel_subscriptions
  @channel_subscriptions ||= ChannelSubscriptions.new(self)
end
device_registrations() click to toggle source

A {Ably::Realtime::Push::DeviceRegistrations} object.

@spec RSH1b

@return [Ably::Realtime::Push::DeviceRegistrations]

# File lib/submodules/ably-ruby/lib/ably/realtime/push/admin.rb, line 51
def device_registrations
  @device_registrations ||= DeviceRegistrations.new(self)
end
publish(recipient, data, &callback) click to toggle source

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]

# File lib/submodules/ably-ruby/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

Private Instance Methods

logger() click to toggle source
# File lib/submodules/ably-ruby/lib/ably/realtime/push/admin.rb, line 70
def logger
  client.logger
end
rest_push_admin() click to toggle source
# File lib/submodules/ably-ruby/lib/ably/realtime/push/admin.rb, line 66
def rest_push_admin
  client.rest_client.push.admin
end