Class: FiveMobilePush::Device
- Inherits:
-
Object
- Object
- FiveMobilePush::Device
- Defined in:
- lib/five_mobile_push/device.rb
Constant Summary collapse
- VALID_OPTION_KEYS =
[:alias, :email]
Instance Attribute Summary collapse
-
#device_uid ⇒ Object
readonly
Returns the value of attribute device_uid.
Instance Method Summary collapse
-
#initialize(client, device_uid) ⇒ Device
constructor
A new instance of Device.
-
#register(device_info, registration_data = nil) ⇒ Hash
Registers a device for receiving push notifications from an application.
- #resume ⇒ Object
- #suspend ⇒ Object
- #unregister ⇒ Object
Constructor Details
#initialize(client, device_uid) ⇒ Device
Returns a new instance of Device.
12 13 14 15 |
# File 'lib/five_mobile_push/device.rb', line 12 def initialize(client, device_uid) @client = client @device_uid = device_uid end |
Instance Attribute Details
#device_uid ⇒ Object (readonly)
Returns the value of attribute device_uid.
6 7 8 |
# File 'lib/five_mobile_push/device.rb', line 6 def device_uid @device_uid end |
Instance Method Details
#register(device_info, registration_data = nil) ⇒ Hash
Registers a device for receiving push notifications from an application. If the device is already registered, this call can update the existing registration details.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/five_mobile_push/device.rb', line 37 def register(device_info, registration_data=nil) = { :device_id => @device_uid, :device_info => MultiJson.encode(device_info) } [:reg_data] = registration_data unless registration_data.nil? response = @client.post 'device/register', MultiJson.decode(response.body) end |
#resume ⇒ Object
48 49 50 |
# File 'lib/five_mobile_push/device.rb', line 48 def resume @client.post 'device/resume', :id_type => FiveMobilePush::DEFAULT_ID_TYPE, :id_value => @device_uid end |
#suspend ⇒ Object
52 53 54 |
# File 'lib/five_mobile_push/device.rb', line 52 def suspend @client.post 'device/suspend', :id_type => FiveMobilePush::DEFAULT_ID_TYPE, :id_value => @device_uid end |
#unregister ⇒ Object
56 57 58 |
# File 'lib/five_mobile_push/device.rb', line 56 def unregister @client.post 'device/unregister', :id_type => FiveMobilePush::DEFAULT_ID_TYPE, :id_value => @device_uid end |