Created
September 25, 2017 12:17
-
-
Save wakim/8e6b3e6e0444e00d71f8f7cedbd6545d to your computer and use it in GitHub Desktop.
Send notification based on platform
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def send_notification | |
fcm = FCM.new(ENV['FIREBASE_SERVER_KEY'], { mutable_content: true, content_available: true, priority: 'high' }) | |
registration_ids = [event_slot.physiotherapist.firebase_token] | |
date = I18n.l(event_slot.appointment_time, format: :short) | |
payload = { data: { title: 'Você tem um novo agendamento', body: "Confirme sua disponibilidade para atender na #{franchise.nome}, #{date}" }, mutable_content: true, content_available: true, priority: 'high' } | |
if (event_slot.physiotherapist.platform == 'ios') | |
payload[:notification] = payload[:data] | |
end | |
fcm.send(registration_ids, payload) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment