class Ably::Rest::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/rest/push/admin.rb, line 17 def initialize(push) @push = push @client = push.client end
Public Instance Methods
channel_subscriptions()
click to toggle source
Manage channel subscriptions for devices or clients
@return [Ably::Rest::Push::ChannelSubscriptions]
# File lib/submodules/ably-ruby/lib/ably/rest/push/admin.rb, line 53 def channel_subscriptions @channel_subscriptions ||= ChannelSubscriptions.new(self) end
device_registrations()
click to toggle source
Manage device registrations
@return [Ably::Rest::Push::DeviceRegistrations]
# File lib/submodules/ably-ruby/lib/ably/rest/push/admin.rb, line 45 def device_registrations @device_registrations ||= DeviceRegistrations.new(self) end
publish(recipient, data)
click to toggle source
Publish a push message directly to a single recipient
@param recipient [Hash] A recipient device, client_id or raw APNS/FCM/web target. Refer to push documentation @param data [Hash] The notification payload data and fields. Refer to push documentation
@return [void]
# File lib/submodules/ably-ruby/lib/ably/rest/push/admin.rb, line 29 def publish(recipient, data) 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? publish_data = data.merge(recipient: IdiomaticRubyWrapper(recipient)) # Co-erce to camelCase for notitication fields which are always camelCase publish_data[:notification] = IdiomaticRubyWrapper(data[:notification]) if publish_data[:notification].kind_of?(Hash) client.post('/push/publish', publish_data) end