Class: Nuntius::FirebasePushProvider

Inherits:
BaseProvider show all
Defined in:
app/providers/nuntius/firebase_push_provider.rb

Instance Attribute Summary

Attributes inherited from BaseProvider

#message

Instance Method Summary collapse

Methods inherited from BaseProvider

all_settings, #callback, class_from_name, #initialize, #name, #refresh, setting_reader, states, transport

Constructor Details

This class inherits a constructor from Nuntius::BaseProvider

Instance Method Details

#deliverObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/providers/nuntius/firebase_push_provider.rb', line 11

def deliver
  fcm = FCM.new(server_key)

  options = (message.payload || {}).merge(data: {body: message.text})
  response = fcm.send([message.to], options)

  message.status = if response[:status_code] != 200 || response[:response] != "success"
    "undelivered"
  else
    "sent"
  end

  message
end