Class: APNS::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/apns/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, auth_key) ⇒ Client

Returns a new instance of Client.



10
11
12
13
# File 'lib/apns/client.rb', line 10

def initialize(uri, auth_key)
  @uri = URI.parse(uri)
  @auth_key = auth_key
end

Instance Attribute Details

#auth_tokenObject (readonly)

Returns the value of attribute auth_token.



8
9
10
# File 'lib/apns/client.rb', line 8

def auth_token
  @auth_token
end

#uriObject (readonly)

Returns the value of attribute uri.



8
9
10
# File 'lib/apns/client.rb', line 8

def uri
  @uri
end

Instance Method Details

#notify(device, notification) ⇒ Object

Send a notification to a device



18
19
20
21
# File 'lib/apns/client.rb', line 18

def notify(device, notification)
  response = make_request(:notify, {:device => device, :notification => notification.to_hash})
  NotificationResponse.new(response)
end

#register(device, label = nil) ⇒ Object

Register a device



26
27
28
29
# File 'lib/apns/client.rb', line 26

def register(device, label = nil)
  response = make_request(:register, {:device => device, :label => label})
  response.success?
end