Class: ActionNativePush::ConfiguredNotification

Inherits:
Object
  • Object
show all
Defined in:
lib/action_native_push/configured_notification.rb

Instance Method Summary collapse

Constructor Details

#initialize(notification_class) ⇒ ConfiguredNotification

Returns a new instance of ConfiguredNotification.



3
4
5
6
# File 'lib/action_native_push/configured_notification.rb', line 3

def initialize(notification_class)
  @notification_class = notification_class
  @options = {}
end

Instance Method Details

#new(**attributes) ⇒ Object



8
9
10
# File 'lib/action_native_push/configured_notification.rb', line 8

def new(**attributes)
  notification_class.new(**attributes.merge(options))
end

#silentObject



17
18
19
20
# File 'lib/action_native_push/configured_notification.rb', line 17

def silent
  @options = options.merge(high_priority: false)
  with_apple(content_available: 1)
end

#with_apple(apple_data) ⇒ Object



22
23
24
25
# File 'lib/action_native_push/configured_notification.rb', line 22

def with_apple(apple_data)
  @options[:apple_data] = @options.fetch(:apple_data, {}).merge(apple_data)
  self
end

#with_data(data) ⇒ Object



12
13
14
15
# File 'lib/action_native_push/configured_notification.rb', line 12

def with_data(data)
  @options[:data] = @options.fetch(:data, {}).merge(data)
  self
end

#with_google(google_data) ⇒ Object



27
28
29
30
# File 'lib/action_native_push/configured_notification.rb', line 27

def with_google(google_data)
  @options[:google_data] = @options.fetch(:google_data, {}).merge(google_data)
  self
end