Packages
pigeon
1.0.1
2.0.1
2.0.0
2.0.0-rc.3
2.0.0-rc.2
2.0.0-rc.1
2.0.0-rc.0
1.6.3
1.6.2
1.6.1
1.6.0
1.5.1
1.5.0
1.4.0
1.3.2
1.3.1
1.3.0
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
1.1.6
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.1.0-rc.1
1.1.0-rc.0
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
0.13.1
0.13.0
0.12.1
0.12.0
0.11.0
0.10.3
0.10.2
0.10.1
0.10.0
0.9.1
0.9.0
0.8.0
0.7.0
0.6.0
0.5.2
0.5.1
0.5.0
0.4.1
0.4.0
0.3.0
0.2.0
0.1.0
iOS (APNS), Android (FCM), and Amazon Android (ADM) push notifications for Elixir.
Current section
Files
Jump to
Current section
Files
lib/pigeon.ex
defmodule Pigeon do
use Application
require Logger
import Supervisor.Spec
@moduledoc """
HTTP2-compliant wrapper for sending iOS and Android push notifications.
"""
def start(_type, _args) do
opts = [strategy: :one_for_one, name: :pigeon]
Supervisor.start_link(workers(), opts)
end
defp workers do
adm_workers() ++ apns_workers() ++ fcm_workers() ++ task_supervisors()
end
def task_supervisors do
[supervisor(Task.Supervisor, [[name: Pigeon.Tasks]])]
end
def adm_workers do
cond do
workers = Application.get_env(:pigeon, :adm) ->
Enum.map(workers, fn({worker_name, _config}) ->
config = Pigeon.ADM.Config.config(worker_name)
worker(Pigeon.ADM.Worker, [config], id: worker_name)
end)
true -> []
end
end
defp apns_workers do
cond do
workers = Application.get_env(:pigeon, :apns) ->
Enum.map(workers, fn({worker_name, _config}) ->
config = Pigeon.APNS.Config.config(worker_name)
worker(Pigeon.APNS.Worker, [config], id: worker_name)
end)
true -> []
end
end
defp fcm_workers do
# cond do
# config = Application.get_env(:pigeon, :fcm) ->
# [worker(Pigeon.FCMWorker, [:fcm_worker, config], id: :fcm_worker)]
# true -> []
# end
cond do
workers = Application.get_env(:pigeon, :fcm) ->
Enum.map(workers, fn({worker_name, config}) ->
config = Map.put(config, :name, worker_name)
worker(Pigeon.FCM.Worker, [config], id: worker_name)
end)
true -> []
end
end
end