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
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#uid ⇒ Object
readonly
Returns the value of attribute uid.
Instance Method Summary collapse
-
#initialize(client, uid, token = nil) ⇒ Device
constructor
A new instance of Device.
-
#register(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, uid, token = nil) ⇒ Device
Returns a new instance of Device.
12 13 14 15 16 |
# File 'lib/five_mobile_push/device.rb', line 12 def initialize(client, uid, token=nil) @client = client @uid = uid @token = token end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
6 7 8 |
# File 'lib/five_mobile_push/device.rb', line 6 def token @token end |
#uid ⇒ Object (readonly)
Returns the value of attribute uid.
6 7 8 |
# File 'lib/five_mobile_push/device.rb', line 6 def uid @uid end |
Instance Method Details
#register(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.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/five_mobile_push/device.rb', line 38 def register(info, registration_data=nil) = { :device_id => @uid, :device_info => MultiJson.encode(info) } [:reg_data] = registration_data unless registration_data.nil? response = @client.post 'device/register', if response.headers['content-type'] =~ /json/i MultiJson.decode(response.body) else response.body end end |
#resume ⇒ Object
54 55 56 |
# File 'lib/five_mobile_push/device.rb', line 54 def resume client_operation 'device/resume' end |
#suspend ⇒ Object
58 59 60 |
# File 'lib/five_mobile_push/device.rb', line 58 def suspend client_operation 'device/suspend' end |
#unregister ⇒ Object
62 63 64 |
# File 'lib/five_mobile_push/device.rb', line 62 def unregister client_operation 'device/unregister' end |