Class: IonicNotification::Notification

Inherits:
Object
  • Object
show all
Defined in:
lib/ionic_notification/notification.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Notification

Returns a new instance of Notification.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ionic_notification/notification.rb', line 6

def initialize(options = {})
  @message_provided = options[:message]

  @tokens = init_tokens(options[:tokens])
  @title ||= options[:title] || default_title
  @message ||= options[:message] || default_message

  if options[:android_payload]
    @android_payload ||= assign_payload(options[:android_payload])
  end

  if options[:ios_payload]
    @ios_payload ||= assign_payload(options[:ios_payload])
  end

  if options[:payload]
    @android_payload ||= assign_payload(options[:payload])
    @ios_payload ||= assign_payload(options[:payload])
  end

  @android_payload ||= default_payload
  @ios_payload ||= default_payload

  @scheduled = options[:scheduled]

  @production = options[:production] || init_production
end

Instance Attribute Details

#android_payloadObject

Returns the value of attribute android_payload.



3
4
5
# File 'lib/ionic_notification/notification.rb', line 3

def android_payload
  @android_payload
end

#ios_payloadObject

Returns the value of attribute ios_payload.



3
4
5
# File 'lib/ionic_notification/notification.rb', line 3

def ios_payload
  @ios_payload
end

#messageObject

Returns the value of attribute message.



3
4
5
# File 'lib/ionic_notification/notification.rb', line 3

def message
  @message
end

#productionObject

Returns the value of attribute production.



3
4
5
# File 'lib/ionic_notification/notification.rb', line 3

def production
  @production
end

#scheduledObject

Returns the value of attribute scheduled.



3
4
5
# File 'lib/ionic_notification/notification.rb', line 3

def scheduled
  @scheduled
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/ionic_notification/notification.rb', line 3

def title
  @title
end

#tokensObject

Returns the value of attribute tokens.



3
4
5
# File 'lib/ionic_notification/notification.rb', line 3

def tokens
  @tokens
end

Instance Method Details

#sendObject



34
35
36
37
38
39
40
41
# File 'lib/ionic_notification/notification.rb', line 34

def send
  if @message_provided || IonicNotification.process_empty_messages
    service = PushService.new self
    service.notify!
  else
    self.class.new_logger.empty_message
  end
end