Commit d82a6716 by Victor Wang

支持链接类型的通知推送

parent 1d03a63b
require 'igetui/template/base_template'
require 'igetui/template/transmission_template'
require 'igetui/template/link_template'
require 'igetui/template/notification_template'
module IGeTui
class LinkTemplate < BaseTemplate
attr_accessor :title, :text, :logo, :logo_url, :url
attr_accessor :is_ring, :is_vibrate, :is_clearable
def initialize
@title = ''
@text = ''
@logo = ''
@logo_url = ''
@transmission_type = 0
@transmission_content = ''
@is_ring = true
@is_vibrate = true
@is_clearable = false
super
end
def get_action_chain
# set actionchain
action_chain_1 = GtReq::ActionChain.new
action_chain_1.actionId = 1
action_chain_1.type = GtReq::ActionChain::Type::Goto
action_chain_1.next = 10000
# notification
action_chain_2 = GtReq::ActionChain.new
action_chain_2.actionId = 10000
action_chain_2.type = GtReq::ActionChain::Type::Notification
action_chain_2.title = title
action_chain_2.text = text
action_chain_2.logo = logo
action_chain_2.logoURL = logo_url
action_chain_2.ring = is_ring
action_chain_2.clearable = is_clearable
action_chain_2.buzz = is_vibrate
action_chain_2.next = 10010
# goto
action_chain_3 = GtReq::ActionChain.new
action_chain_3.actionId = 10010
action_chain_3.type = GtReq::ActionChain::Type::Goto
action_chain_3.next = 10030
# start web
action_chain_4 = GtReq::ActionChain.new
action_chain_4.actionId = 10030
action_chain_4.type = GtReq::ActionChain::Type::Startweb
action_chain_4.url = url
action_chain_4.next = 100
# end
action_chain_5 = GtReq::ActionChain.new
action_chain_5.actionId = 100
action_chain_5.type = GtReq::ActionChain::Type::Eoa
[action_chain_1, action_chain_2, action_chain_3, action_chain_4, action_chain_5]
end
def get_push_type
"NotifyMsg"
end
end
end
......@@ -18,49 +18,49 @@ module IGeTui
def get_action_chain
# set actionchain
actionChain1 = GtReq::ActionChain.new
actionChain1.actionId = 1
actionChain1.type = GtReq::ActionChain::Type::Goto
actionChain1.next = 10000
action_chain_1 = GtReq::ActionChain.new
action_chain_1.actionId = 1
action_chain_1.type = GtReq::ActionChain::Type::Goto
action_chain_1.next = 10000
# notification
actionChain2 = GtReq::ActionChain.new
actionChain2.actionId = 10000
actionChain2.type = GtReq::ActionChain::Type::Notification
actionChain2.title = title
actionChain2.text = text
actionChain2.logo = logo
actionChain2.logoURL = logo_url
actionChain2.ring = is_ring
actionChain2.clearable = is_clearable
actionChain2.buzz = is_vibrate
actionChain2.next = 10010
action_chain_2 = GtReq::ActionChain.new
action_chain_2.actionId = 10000
action_chain_2.type = GtReq::ActionChain::Type::Notification
action_chain_2.title = title
action_chain_2.text = text
action_chain_2.logo = logo
action_chain_2.logoURL = logo_url
action_chain_2.ring = is_ring
action_chain_2.clearable = is_clearable
action_chain_2.buzz = is_vibrate
action_chain_2.next = 10010
# goto
actionChain3 = GtReq::ActionChain.new
actionChain3.actionId = 10010
actionChain3.type = GtReq::ActionChain::Type::Goto
actionChain3.next = 10030
action_chain_3 = GtReq::ActionChain.new
action_chain_3.actionId = 10010
action_chain_3.type = GtReq::ActionChain::Type::Goto
action_chain_3.next = 10030
# appStartUp
appStartUp = GtReq::AppStartUp.new(android: '', symbia: '', ios: '')
app_start_up = GtReq::AppStartUp.new(android: '', symbia: '', ios: '')
# start web
actionChain4 = GtReq::ActionChain.new
actionChain4.actionId = 10030
actionChain4.type = GtReq::ActionChain::Type::Startapp
actionChain4.appid = ''
actionChain4.autostart = @transmission_type == 1
actionChain4.appstartupid = appStartUp
actionChain4.failedAction = 100
actionChain4.next = 100
action_chain_4 = GtReq::ActionChain.new
action_chain_4.actionId = 10030
action_chain_4.type = GtReq::ActionChain::Type::Startapp
action_chain_4.appid = ''
action_chain_4.autostart = @transmission_type == 1
action_chain_4.appstartupid = app_start_up
action_chain_4.failedAction = 100
action_chain_4.next = 100
# end
actionChain5 = GtReq::ActionChain.new
actionChain5.actionId = 100
actionChain5.type = GtReq::ActionChain::Type::Eoa
action_chain_5 = GtReq::ActionChain.new
action_chain_5.actionId = 100
action_chain_5.type = GtReq::ActionChain::Type::Eoa
[actionChain1, actionChain2, actionChain3, actionChain4, actionChain5]
[action_chain_1, action_chain_2, action_chain_3, action_chain_4, action_chain_5]
end
def get_push_type
......
......@@ -8,30 +8,30 @@ module IGeTui
def get_action_chain
# set actionChain
actionChain1 = GtReq::ActionChain.new
actionChain1.actionId = 1
actionChain1.type = GtReq::ActionChain::Type::Goto
actionChain1.next = 10030
action_chain_1 = GtReq::ActionChain.new
action_chain_1.actionId = 1
action_chain_1.type = GtReq::ActionChain::Type::Goto
action_chain_1.next = 10030
# appStartUp
appStartUp = GtReq::AppStartUp.new(android: '', symbia: '', ios: '')
app_start_up = GtReq::AppStartUp.new(android: '', symbia: '', ios: '')
# start up app
actionChain2 = GtReq::ActionChain.new
actionChain2.actionId = 10030
actionChain2.type = GtReq::ActionChain::Type::Startapp
actionChain2.appid = ''
actionChain2.autostart = transmission_type == 1
actionChain2.appstartupid = appStartUp
actionChain2.failedAction = 100
actionChain2.next = 100
action_chain_2 = GtReq::ActionChain.new
action_chain_2.actionId = 10030
action_chain_2.type = GtReq::ActionChain::Type::Startapp
action_chain_2.appid = ''
action_chain_2.autostart = transmission_type == 1
action_chain_2.appstartupid = app_start_up
action_chain_2.failedAction = 100
action_chain_2.next = 100
# end
actionChain3 = GtReq::ActionChain.new
actionChain3.actionId = 100
actionChain3.type = GtReq::ActionChain::Type::Eoa
action_chain_3 = GtReq::ActionChain.new
action_chain_3.actionId = 100
action_chain_3.type = GtReq::ActionChain::Type::Eoa
[actionChain1, actionChain2, actionChain3]
[action_chain_1, action_chain_2, action_chain_3]
end
def get_push_type
......
module IGeTui
VERSION = "0.0.1"
VERSION = "0.0.2"
end
......@@ -28,6 +28,13 @@ class PusherTest < MiniTest::Unit::TestCase
assert_equal ret["result"], "ok"
end
def test_to_single_link_notification
single_message = IGeTui::SingleMessage.new
single_message.data = link_template
ret = @pusher.push_message_to_single(single_message, @client_1)
assert_equal ret["result"], "ok"
end
def test_to_single_transmission
single_message = IGeTui::SingleMessage.new
single_message.data = transmission_template
......@@ -56,12 +63,23 @@ class PusherTest < MiniTest::Unit::TestCase
private
def notification_template
template = IGeTui::NotificationTemplate.new
def set_template_base_info(template)
template.logo = 'push.png'
template.logo_url = 'http://www.igetui.com/wp-content/uploads/2013/08/logo_getui1.png'
template.title = '测试标题'
template.text = '测试文本'
end
def link_template
template = IGeTui::LinkTemplate.new
set_template_base_info(template)
template.url = "http://www.baidu.com"
template
end
def notification_template
template = IGeTui::NotificationTemplate.new
set_template_base_info(template)
template
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment