Class: Maia::FCM::Platform::APNS

Inherits:
Object
  • Object
show all
Defined in:
lib/maia/fcm/platform/apns.rb

Instance Method Summary collapse

Constructor Details

#initialize(message) ⇒ APNS

Returns a new instance of APNS.



5
6
7
# File 'lib/maia/fcm/platform/apns.rb', line 5

def initialize(message)
  @message = message
end

Instance Method Details

#badgeObject



9
10
11
# File 'lib/maia/fcm/platform/apns.rb', line 9

def badge
  @message.badge
end

#priorityObject



17
18
19
20
21
22
23
# File 'lib/maia/fcm/platform/apns.rb', line 17

def priority
  if @message.priority == :high && !@message.background?
    10
  else
    5
  end
end

#soundObject



13
14
15
# File 'lib/maia/fcm/platform/apns.rb', line 13

def sound
  @message.sound
end

#to_hObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/maia/fcm/platform/apns.rb', line 25

def to_h
  {
    headers: {
      'apns-priority': priority.to_s
    }.compact,
    payload: {
      aps: {
        badge: badge,
        sound: sound,
        'content-available': (1 if @message.background?)
      }.compact
    }
  }
end