Class: JPush::PushClient

Inherits:
Object
  • Object
show all
Defined in:
lib/jpush/push_client.rb

Constant Summary collapse

@@PUSH_API_URL =
'https://api.jpush.cn/v3/push'
@@_timeToLive =
60 * 60 * 24

Instance Method Summary collapse

Constructor Details

#initialize(maxRetryTimes) ⇒ PushClient

Returns a new instance of PushClient.



14
15
16
# File 'lib/jpush/push_client.rb', line 14

def initialize(maxRetryTimes)
  @httpclient = JPush::NativeHttpClient.new(maxRetryTimes)
end

Instance Method Details

#sendPush(payload, autoCode) ⇒ Object

Parameters:

  • payload

    is the instance of PushPayload



22
23
24
25
26
27
28
# File 'lib/jpush/push_client.rb', line 22

def sendPush(payload,autoCode)
  json_data = JSON.generate(payload.toJSON)
  result = JPush::PushResult.new
  wrapper = @httpclient.sendPost(@@PUSH_API_URL, json_data, autoCode)
  result.fromResponse(wrapper)
  return result
end