Class: Xiaomipush::AndroidBuilder

Inherits:
Message
  • Object
show all
Defined in:
lib/xiaomipush/android_builder.rb

Constant Summary collapse

NOTIFY_TYPE_DEFAULT_ALL =

设置通知类型

-1
NOTIFY_TYPE_DEFAULT_SOUND =

使用默认提示音提示

1
NOTIFY_TYPE_DEFAULT_VIBRATE =

使用默认震动提示

2
NOTIFY_TYPE_DEFAULT_LIGHTS =

使用默认led灯光提示

4
NTF_CENTER_NTF =

通知栏消息

0
PASS_THROUGH_NTF =

透传消息

1

Constants inherited from Message

Message::EXTRA_PREFIX

Instance Attribute Summary collapse

Attributes inherited from Message

#description, #extra, #notify_type, #payload, #restricted_package_name, #time_to_live, #time_to_send, #title

Instance Method Summary collapse

Constructor Details

#initialize(**message) ⇒ AndroidBuilder

Returns a new instance of AndroidBuilder.



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/xiaomipush/android_builder.rb', line 15

def initialize(**message)
  super(message)
  puts "======> send push message====>: #{message.inspect}"
  extra = message.delete(:extra) if message[:extra]
  @pass_through = message[:pass_through] || NTF_CENTER_NTF
  @notify_id = message[:notify_id] || 0
  @notify_type  = message[:notify_type] || NOTIFY_TYPE_DEFAULT_ALL
  extra_message = {sound_url: ""}
  extra_message.merge!(extra) if extra
  @extra = extra_message
end

Instance Attribute Details

#notify_idObject

Returns the value of attribute notify_id.



13
14
15
# File 'lib/xiaomipush/android_builder.rb', line 13

def notify_id
  @notify_id
end

#pass_throughObject

Returns the value of attribute pass_through.



13
14
15
# File 'lib/xiaomipush/android_builder.rb', line 13

def pass_through
  @pass_through
end

#sound_urlObject

Returns the value of attribute sound_url.



13
14
15
# File 'lib/xiaomipush/android_builder.rb', line 13

def sound_url
  @sound_url
end

Instance Method Details

#buildObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/xiaomipush/android_builder.rb', line 27

def build
  extra_message = extra(@extra) if @extra
  message = {
    payload: @payload,
    title: @title,
    notify_id: @notify_id,
    pass_through: @pass_through,
    notify_type: @notify_type,
    restricted_package_name: @restricted_package_name,
    description: @description
  }
  message.merge!(extra_message)
  puts "======> send push message_merge====>: #{message.inspect}"
  return message
end