Class: UmengPush::Client
- Inherits:
-
Object
- Object
- UmengPush::Client
- Defined in:
- lib/umeng_push/client.rb
Instance Attribute Summary collapse
-
#app_master_secret ⇒ Object
Returns the value of attribute app_master_secret.
-
#appkey ⇒ Object
Returns the value of attribute appkey.
-
#platform ⇒ Object
Returns the value of attribute platform.
-
#production_mode ⇒ Object
Returns the value of attribute production_mode.
Class Method Summary collapse
Instance Method Summary collapse
-
#broadcast(params = {}) ⇒ Object
广播.
-
#cancel_task(task_id) ⇒ Object
取消任务.
-
#check_task(task_id) ⇒ Object
查询任务.
-
#groupcast(filter = {}, params = {}) ⇒ Object
组播.
-
#initialize(platform, appkey, app_master_secret, production_mode = false) ⇒ Client
constructor
A new instance of Client.
-
#listcast(device_tokens = [], params = {}) ⇒ Object
组播.
-
#send_message(params = {}) ⇒ Object
消息发送.
-
#unicast(device_token, params = {}) ⇒ Object
单播.
Constructor Details
#initialize(platform, appkey, app_master_secret, production_mode = false) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 |
# File 'lib/umeng_push/client.rb', line 8 def initialize(platform, appkey, app_master_secret, production_mode=false) @platform = platform @appkey = appkey @app_master_secret = app_master_secret @production_mode = production_mode end |
Instance Attribute Details
#app_master_secret ⇒ Object
Returns the value of attribute app_master_secret.
7 8 9 |
# File 'lib/umeng_push/client.rb', line 7 def app_master_secret @app_master_secret end |
#appkey ⇒ Object
Returns the value of attribute appkey.
7 8 9 |
# File 'lib/umeng_push/client.rb', line 7 def appkey @appkey end |
#platform ⇒ Object
Returns the value of attribute platform.
7 8 9 |
# File 'lib/umeng_push/client.rb', line 7 def platform @platform end |
#production_mode ⇒ Object
Returns the value of attribute production_mode.
7 8 9 |
# File 'lib/umeng_push/client.rb', line 7 def production_mode @production_mode end |
Class Method Details
.android ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/umeng_push/client.rb', line 24 def self.android Client.new( "android", UmengPush.configuration.android_appkey, UmengPush.configuration.android_app_master_secret, UmengPush.configuration.production_mode ) end |
.iOS ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/umeng_push/client.rb', line 15 def self.iOS Client.new( "iOS", UmengPush.configuration.ios_appkey, UmengPush.configuration.ios_app_master_secret, UmengPush.configuration.production_mode ) end |
Instance Method Details
#broadcast(params = {}) ⇒ Object
广播
59 60 61 62 63 |
# File 'lib/umeng_push/client.rb', line 59 def broadcast(params={}) (params.merge({ type: "broadcast" })) end |
#cancel_task(task_id) ⇒ Object
取消任务
83 84 85 86 87 88 89 |
# File 'lib/umeng_push/client.rb', line 83 def cancel_task(task_id) post("/api/cancel", { appkey: appkey, timestamp: , task_id: task_id }) end |
#check_task(task_id) ⇒ Object
查询任务
74 75 76 77 78 79 80 |
# File 'lib/umeng_push/client.rb', line 74 def check_task(task_id) post("/api/status", { appkey: appkey, timestamp: , task_id: task_id }) end |
#groupcast(filter = {}, params = {}) ⇒ Object
组播
66 67 68 69 70 71 |
# File 'lib/umeng_push/client.rb', line 66 def groupcast(filter={}, params={}) (params.merge({ type: "groupcast", filter: filter })) end |
#listcast(device_tokens = [], params = {}) ⇒ Object
组播
51 52 53 54 55 56 |
# File 'lib/umeng_push/client.rb', line 51 def listcast(device_tokens=[], params={}) (params.merge({ type: "listcast", device_tokens: device_tokens.join(",") })) end |
#send_message(params = {}) ⇒ Object
消息发送
34 35 36 37 38 39 40 |
# File 'lib/umeng_push/client.rb', line 34 def (params={}) post("/api/send", params.merge({ appkey: appkey, timestamp: , production_mode: production_mode })) end |
#unicast(device_token, params = {}) ⇒ Object
单播
43 44 45 46 47 48 |
# File 'lib/umeng_push/client.rb', line 43 def unicast(device_token, params={}) (params.merge({ type: "unicast", device_tokens: device_token })) end |