Commit a14652b3 by 李福中

Merge branch 'master' into release

parents 1ab512d5 d2b2b524
...@@ -13,7 +13,7 @@ module Push ...@@ -13,7 +13,7 @@ module Push
device_tokens.each_slice(BATCH_PUSH_MAX) do |device_token_array| device_tokens.each_slice(BATCH_PUSH_MAX) do |device_token_array|
res = res_push(message, device_token_array) res = res_push(message, device_token_array)
# 容错处理,华为的token异常问题,重新获取发送。 # 容错处理,华为的token异常问题,重新获取发送。
if res['code'] == '80300002' if %w(80300002 80200001).include? res['code']
handle_token_res handle_token_res
res_push(message, device_token_array) res_push(message, device_token_array)
end end
......
...@@ -5,6 +5,7 @@ module Push ...@@ -5,6 +5,7 @@ module Push
PUSHERTYPES = %w[push_message_to_single push_message_to_list push_message_to_app].freeze PUSHERTYPES = %w[push_message_to_single push_message_to_list push_message_to_app].freeze
TEMPLATETYPES = %w[LinkTemplate NotificationTemplate TransmissionTemplate NotyPopLoadTemplate].freeze TEMPLATETYPES = %w[LinkTemplate NotificationTemplate TransmissionTemplate NotyPopLoadTemplate].freeze
DEVICEPLATFORMS = %w[android ios].freeze
def initialize(template_data, opts = {}) def initialize(template_data, opts = {})
...@@ -14,6 +15,7 @@ module Push ...@@ -14,6 +15,7 @@ module Push
@pusher_type = PUSHERTYPES.include?((opts[:pusher_type]).to_s) ? opts[:pusher_type] : 'push_message_to_single' @pusher_type = PUSHERTYPES.include?((opts[:pusher_type]).to_s) ? opts[:pusher_type] : 'push_message_to_single'
@template_type = TEMPLATETYPES.include?((opts[:template_type]).to_s) ? opts[:template_type] : 'NotificationTemplate' @template_type = TEMPLATETYPES.include?((opts[:template_type]).to_s) ? opts[:template_type] : 'NotificationTemplate'
::Push::Log.info("@template_data is #{@template_data.to_json}")
set_message set_message
set_template_data set_template_data
@message.data = @template @message.data = @template
...@@ -42,11 +44,27 @@ module Push ...@@ -42,11 +44,27 @@ module Push
private private
def pusher def pusher
@pusher ||= IGeTui.pusher( @pusher ||=
Settings.platform_settings.igetui['app_id'], if DEVICEPLATFORMS.include?((@template_data['device_platform'].to_s))
Settings.platform_settings.igetui['app_key'], case @template_data['device_platform'].to_s
Settings.platform_settings.igetui['master_secret']
) when 'android'
IGeTui.pusher(
Settings.platform_settings.igetui.android['app_id'],
Settings.platform_settings.igetui.android['app_key'],
Settings.platform_settings.igetui.android['master_secret']
)
when 'ios'
IGeTui.pusher(
Settings.platform_settings.igetui.ios['app_id'],
Settings.platform_settings.igetui.ios['app_key'],
Settings.platform_settings.igetui.ios['master_secret']
)
end
else
::Push::Log.info("设备类型不正确#{@device_platform}")
raise "Failed to create pusher"
end
end end
def set_message def set_message
......
...@@ -2,7 +2,7 @@ class Settings < Settingslogic ...@@ -2,7 +2,7 @@ class Settings < Settingslogic
source "#{Rails.root}/config/settings.yml" source "#{Rails.root}/config/settings.yml"
namespace Rails.env namespace Rails.env
PLATFORM = %w[ik_duli lx_duli lx_yun] PLATFORM = %w[ik_duli lx_duli lx_yun aike_yun]
DEFAULT = 'ik_duli'.freeze DEFAULT = 'ik_duli'.freeze
def self.platform=(platform) def self.platform=(platform)
...@@ -16,5 +16,4 @@ class Settings < Settingslogic ...@@ -16,5 +16,4 @@ class Settings < Settingslogic
def self.platform_settings def self.platform_settings
self.send(platform) self.send(platform)
end end
end
end
\ No newline at end of file
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