Skip to content

Instantly share code, notes, and snippets.

@wakim
Created September 25, 2017 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wakim/8e6b3e6e0444e00d71f8f7cedbd6545d to your computer and use it in GitHub Desktop.
Save wakim/8e6b3e6e0444e00d71f8f7cedbd6545d to your computer and use it in GitHub Desktop.
Send notification based on platform
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