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
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
11
12
13
14
15
|
# File 'lib/jpush/push/notification.rb', line 11
def set_alert(alert)
Notification.ensure_argument_not_blank('alert': alert)
@alert = alert
self
end
|
#set_android(alert:, title: nil, builder_id: nil, extras: nil) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/jpush/push/notification.rb', line 22
def set_android(alert: , title: nil, builder_id: nil, extras: nil)
= Notification.()
check_argument(alert: alert, title: title, builder_id: builder_id)
@android = {
alert: alert,
title: title,
builder_id: builder_id,
extras:
}.compact
self
end
|
#set_ios(alert:, sound: nil, badge: nil, available: nil, category: nil, extras: nil) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/jpush/push/notification.rb', line 34
def set_ios(alert: , sound: nil, badge: nil, available: nil, category:nil, extras: nil)
= Notification.()
badge = 0 == badge.to_i ? '0' : badge unless badge.nil?
available = nil unless available.is_a? TrueClass
check_argument(alert: alert, sound: sound, badge: badge, category: category)
@ios = {
alert: alert,
sound: sound,
badge: badge,
'content-available': available,
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
51
52
53
54
55
56
57
58
59
|
# File 'lib/jpush/push/notification.rb', line 51
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
|