Class: HeyYouFcmPush::MessageObject::AndroidConfig
- Inherits:
-
Object
- Object
- HeyYouFcmPush::MessageObject::AndroidConfig
- Defined in:
- lib/hey_you_fcm_push/message_object/android_config.rb
Instance Attribute Summary collapse
-
#to_h ⇒ Object
readonly
Returns the value of attribute to_h.
Instance Method Summary collapse
- #build_notification(notification) ⇒ Object
-
#initialize(**options) ⇒ AndroidConfig
constructor
A new instance of AndroidConfig.
Constructor Details
#initialize(**options) ⇒ AndroidConfig
Returns a new instance of AndroidConfig.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/hey_you_fcm_push/message_object/android_config.rb', line 6 def initialize(**) [:fcm_options] = [:fcm_options]&.transform_keys(&:to_sym) [:notification] = [:notification]&.transform_keys(&:to_sym) @to_h = { collapse_key: [:collapse_key], priority: [:priority], ttl: [:ttl], restricted_package_name: [:restricted_package_name], data: [:data], notification: build_notification([:notification]), fcm_options: ( FcmOptions.new(analytics_label: [:fcm_options][:analytics_label]).to_h if [:fcm_options] ), direct_boot_ok: [:direct_boot_ok] }.compact end |
Instance Attribute Details
#to_h ⇒ Object (readonly)
Returns the value of attribute to_h.
4 5 6 |
# File 'lib/hey_you_fcm_push/message_object/android_config.rb', line 4 def to_h @to_h end |
Instance Method Details
#build_notification(notification) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/hey_you_fcm_push/message_object/android_config.rb', line 24 def build_notification(notification) return if !notification || notification == {} { title: notification[:title], body: notification[:body], icon: notification[:icon], color: notification[:color], sound: notification[:sound], tag: notification[:tag], click_action: notification[:click_action], body_loc_key: notification[:body_loc_key], body_loc_args: notification[:body_loc_args], title_loc_key: notification[:title_loc_key], title_loc_args: notification[:title_loc_args], channel_id: notification[:channel_id], ticker: notification[:ticker], sticky: notification[:sticky], event_time: notification[:event_time], local_only: notification[:local_only], notification_priority: notification[:notification_priority], default_sound: notification[:default_sound], default_vibrate_timings: notification[:default_vibrate_timings], default_light_settings: notification[:default_light_settings], vibrate_timings: notification[:vibrate_timings], visibility: notification[:visibility], notification_count: notification[:notification_count], light_settings: notification[:light_settings], image: notification[:image] }.compact end |