Named User
Named User Listing
Named User lists are fetched by instantiating an iterator object
using NamedUserList
.
For more information, see the API documentation
require 'urbanairship'
UA = Urbanairship
airship = UA::Client.new(key:'application_key', secret:'master_secret')
named_user_list = UA::NamedUserList.new(client: airship)
named_user_list.each do |named_user|
puts(named_user)
end
Association
Associate a channel with a named user ID. For more information, see the API documentation
require 'urbanairship'
UA = Urbanairship
airship = UA::Client.new(key:'application_key', secret:'app_or_master_secret')
named_user = UA::NamedUser.new(client: airship)
named_user.named_user_id = 'named_user'
named_user.associate(channel_id: 'channel_id', device_type: 'ios')
Note
Do not include a device_type
for Web and Open platform associations.
Disassociation
Remove a channel from the list of associated channels for a named user. For more information, see the API documentation
require 'urbanairship'
UA = Urbanairship
airship = UA::Client.new(key:'application_key', secret:'app_or_master_secret')
named_user = UA::NamedUser.new(client: airship)
named_user.disassociate(channel_id: 'channel_id', device_type: 'ios')
Note
named_user_id
does not have to be set on the named_user object for this
method call since channel_id
can only be associated with one named user.
Do not include a device_type
for Web and Open platform disassociations.
Lookup
Look up a single named user. For more information, see the API documentation
require 'urbanairship'
UA = Urbanairship
airship = UA::Client.new(key:'application_key', secret:'master_secret')
named_user = UA::NamedUser.new(client: airship)
named_user.named_user_id = 'named_user'
user = named_user.lookup
Attributes
Set or remove attributes on a named user. For more information, see `the API documentation https://docs.airship.com/api/ua/#operation-api-named_users-named_user_id-attributes-post>`__
require 'urbanairship'
airship = Urbanairship::Client.new(key: 'application_key', secret: 'master_secret')
named_user = Urbanairship::NamedUser.new(client: airship)
named_user.named_user_id = 'named_user'
named_user.update_attributes(attributes: [
{ action: 'set', key: 'first_name', value: 'Firstname' },
{ action: 'remove', key: 'nickname' },
{ action: 'set', key: 'last_name', value: 'Lastname', timestamp: Time.now.utc }
])
Note
Timestamp is optional, if missing it will default to ‘now’.