Class: APNS::Service
- Inherits:
-
Object
- Object
- APNS::Service
- Includes:
- ActiveModel::Model
- Defined in:
- lib/mercurius/apns/service.rb
Constant Summary collapse
- MAX_NUMBER_OF_RETRIES =
3
Instance Attribute Summary collapse
-
#attempts ⇒ Object
readonly
Returns the value of attribute attempts.
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#host ⇒ Object
Returns the value of attribute host.
-
#pem ⇒ Object
Returns the value of attribute pem.
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
- #deliver(notification, *device_tokens) ⇒ Object
-
#initialize ⇒ Service
constructor
A new instance of Service.
- #persist(&block) ⇒ Object
Constructor Details
Instance Attribute Details
#attempts ⇒ Object (readonly)
Returns the value of attribute attempts.
8 9 10 |
# File 'lib/mercurius/apns/service.rb', line 8 def attempts @attempts end |
#connection ⇒ Object
Returns the value of attribute connection.
7 8 9 |
# File 'lib/mercurius/apns/service.rb', line 7 def connection @connection end |
#host ⇒ Object
Returns the value of attribute host.
7 8 9 |
# File 'lib/mercurius/apns/service.rb', line 7 def host @host end |
#pem ⇒ Object
Returns the value of attribute pem.
7 8 9 |
# File 'lib/mercurius/apns/service.rb', line 7 def pem @pem end |
#port ⇒ Object
Returns the value of attribute port.
7 8 9 |
# File 'lib/mercurius/apns/service.rb', line 7 def port @port end |
Instance Method Details
#deliver(notification, *device_tokens) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/mercurius/apns/service.rb', line 26 def deliver(notification, *device_tokens) device_tokens = Array(device_tokens).flatten with_connection do |connection| device_tokens.each do |device_token| connection.write notification.pack(device_token) end end end |
#persist(&block) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/mercurius/apns/service.rb', line 19 def persist(&block) @_persistent = true yield @_persistent = false connection.close end |