Packages
raxol_watch
0.1.0
Watch notification bridge for Raxol. Pushes glanceable summaries and accessibility announcements to Apple Watch (APNS) and Wear OS (FCM). Tap actions route back as events to the TEA app.
Current section
Files
Jump to
Current section
Files
lib/raxol/watch/push/noop.ex
defmodule Raxol.Watch.Push.Noop do
@moduledoc """
Silent push backend for testing.
Records all push calls so tests can assert on what was sent.
"""
@behaviour Raxol.Watch.Push.Backend
use Agent
require Logger
@mix_env if Code.ensure_loaded?(Mix), do: Mix.env(), else: :prod
def start_link(_opts \\ []) do
if @mix_env not in [:test, :dev] do
Logger.warning("Raxol.Watch.Push.Noop is running outside test/dev -- push notifications will be silently discarded. Configure a real backend (APNS/FCM) for production.")
end
Agent.start_link(fn -> [] end, name: __MODULE__)
end
@impl true
def push(device_token, notification) do
Agent.update(__MODULE__, &[{device_token, notification} | &1])
:ok
end
@doc "Returns all pushes sent, newest first."
@spec get_pushes() :: [{String.t(), map()}]
def get_pushes do
Agent.get(__MODULE__, & &1)
end
@doc "Clears the push history."
@spec clear() :: :ok
def clear do
Agent.update(__MODULE__, fn _ -> [] end)
end
end