Commit 56e473d6 by 杨璇

Merge branch 'fix/xiaomi_push' into testing

parents 35285f68 82acbcb2
module Igetui
class Pusher
def initialize(user_device_ids, opts)
opts = HashWithIndifferentAccess.new(opts)
@template_data = opts[:message]
......@@ -10,7 +10,7 @@ module Igetui
@pusher_type = @igetui_opts[:pusher_type]
@uuid = Random.uuid.to_s
end
def perform
@template_data[:push_type] ||= 2
@igetui_opts[:transmission_type] ||= 0
......@@ -21,7 +21,7 @@ module Igetui
result = push_message_to(@pusher, @pusher_type, template_type, template_data, @user_device_ids)
::Log.info("igetui_push: \n template_data: #{template_data}\n user_device_ids: #{@user_device_ids}\n response: #{result}", @uuid)
end
private
def pusher(device_platform, app_type)
case app_type
......@@ -44,7 +44,7 @@ module Igetui
when 'push_message_to_single'
message = IGeTui::SingleMessage.new
message.data = template
client_id_list.map do |client_id|
client = IGeTui::Client.new(client_id)
res = pusher.push_message_to_single(message, client)
......@@ -53,18 +53,18 @@ module Igetui
when 'push_message_to_list'
message = IGeTui::ListMessage.new
message.data = template
content_id = pusher.get_content_id(message)
clients = client_id_list.map { |client_id| IGeTui::Client.new(client_id) }
res = pusher.push_message_to_list(content_id, clients)
::Log.info("push_message_to_list clients: #{clients.to_json} and message is #{message.to_json} and res is #{res}", @uuid)
when 'push_message_to_app'
message = IGeTui::AppMessage.new
message.data = template
message.app_id_list = client_id_list
res = pusher.push_message_to_app(message)
::Log.info("push_message_to_app message is #{message.to_json} and res is #{res}", @uuid)
end
......@@ -75,7 +75,7 @@ module Igetui
case template_type
when 'NotificationTemplate', 'NotyPopLoadTemplate', 'LinkTemplate'
template_data.reverse_merge!(Settings.platform_settings.igetui['template_base'])
template_data.each do |k, v|
@template.send("#{k}=", v)
end
......
......@@ -2,7 +2,7 @@ module Xiaomi
class Pusher
PUSH_URL = 'https://api.xmpush.xiaomi.com/v3/message/regid'.freeze
BATCH_PUSH_MAX = 80
def initialize(device_ids, message, app_type)
@registration_ids = device_ids
@payload = message
......@@ -39,10 +39,10 @@ module Xiaomi
# 0 表示通知栏消息, 1 表示透传消息
def config
restricted_package_name = Settings.send(@app_type).xiaomi['package_name']
{
restricted_package_name: restricted_package_name,
pass_through: 1,
pass_through: 0,
title: 'xiaomi push',
description: 'xiaomi push',
notify_type: 1
......
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