Class: FiveMobilePush::Device
- Inherits:
-
Object
- Object
- FiveMobilePush::Device
- Defined in:
- lib/five_mobile_push/device.rb
Constant Summary
- VALID_OPTION_KEYS =
[:alias, :email]
Instance Attribute Summary (collapse)
-
- (Object) device_uid
readonly
Returns the value of attribute device_uid.
Instance Method Summary (collapse)
-
- (Device) initialize(client, device_uid)
constructor
A new instance of Device.
-
- (Hash) register(device_info, registration_data = nil)
Registers a device for receiving push notifications from an application.
- - (Object) resume
- - (Object) suspend
- - (Object) unregister
Constructor Details
- (Device) initialize(client, device_uid)
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
- (Object) device_uid (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
- (Hash) register(device_info, registration_data = nil)
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 |
- (Object) resume
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 |
- (Object) suspend
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 |
- (Object) unregister
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 |