Class: JPush::Push::Notification
Constant Summary
collapse
- MAX_IOS_NOTIFICATION_SIZE =
2000
Helper::ArgumentHelper::MAX_ALIAS_ARRAY_SIZE, Helper::ArgumentHelper::MAX_MSG_IDS_ARRAY_SIZE, Helper::ArgumentHelper::MAX_REGISTRATION_ID_ARRAY_SIZE, Helper::ArgumentHelper::MAX_TAG_ARRAY_MAX_BYTESIZE, Helper::ArgumentHelper::MAX_TAG_ARRAY_SZIE
Helper::Argument::MAX_ALIAS_BYTESIZE, Helper::Argument::MAX_TAG_BYTESIZE, Helper::Argument::MOBILE_RE
Instance Method Summary
collapse
-
#set_alert(alert) ⇒ Object
-
#set_android(alert:, title: nil, builder_id: nil, priority: nil, category: nil, style: nil, big_text: nil, inbox: nil, big_pic_path: nil, extras: nil) ⇒ Object
-
#set_ios(alert:, sound: nil, badge: '+1', available: nil, category: nil, extras: nil, contentavailable: nil, mutablecontent: nil) ⇒ Object
-
#set_not_alert ⇒ Object
-
#to_hash ⇒ Object
build_alias, build_extras, build_msg_ids, build_platform, build_registration_ids, build_tags, extended
#check_alias, #check_mobile, #check_platform, #check_registration_id, #check_tag, #ensure_argument_not_blank, #ensure_argument_required, #ensure_not_over_bytesize, #ensure_not_over_size, #ensure_word_valid
Instance Method Details
#set_alert(alert) ⇒ Object
#set_android(alert:, title: nil, builder_id: nil, priority: nil, category: nil, style: nil, big_text: nil, inbox: nil, big_pic_path: nil, extras: nil) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/jpush/push/notification.rb', line 22
def set_android(alert: , title: nil, builder_id: nil,
priority: nil, category: nil, style: nil, big_text: nil, inbox: nil, big_pic_path: nil, extras: nil)
= Notification.()
@android = {
alert: alert,
title: title,
builder_id: builder_id,
priority: priority,
category: category,
style: style,
big_text: big_text,
inbox: inbox,
big_pic_path: big_pic_path,
extras:
}.compact
self
end
|
#set_ios(alert:, sound: nil, badge: '+1', available: nil, category: nil, extras: nil, contentavailable: nil, mutablecontent: nil) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/jpush/push/notification.rb', line 40
def set_ios(alert: , sound: nil, badge: '+1', available: nil, category:nil, extras: nil, contentavailable: nil, mutablecontent: nil)
contentavailable = available if contentavailable.nil?
= Notification.()
contentavailable = nil unless contentavailable.is_a? TrueClass
mutablecontent = nil unless mutablecontent.is_a? TrueClass
@ios = {
alert: alert,
sound: sound,
badge: badge,
'content-available': contentavailable,
'mutable-content': mutablecontent,
category: category,
extras:
}.compact
Notification.ensure_not_over_bytesize('ios', {'ios': @ios}, MAX_IOS_NOTIFICATION_SIZE)
self
end
|
#set_not_alert ⇒ Object
17
18
19
20
|
# File 'lib/jpush/push/notification.rb', line 17
def set_not_alert
@alert = ''
self
end
|
#to_hash ⇒ Object
58
59
60
61
62
63
64
65
66
|
# File 'lib/jpush/push/notification.rb', line 58
def to_hash
@notification = {
alert: @alert,
android: @android,
ios: @ios
}.compact
raise Utils::Exceptions::JPushError, 'Notification can not be empty.' if @notification.empty?
@notification
end
|