Local and push notifications.
Requires :notifications permission (request via Dala.Permissions.request/2).
All notifications arrive via handle_info regardless of app state (foreground,
background, or relaunched after being killed). No special mount/3 handling needed.
Local notifications
Dala.Notify.schedule(socket,
id: "reminder_1",
title: "Time to check in",
body: "Open the app to see today's updates",
at: ~U[2026-04-16 09:00:00Z], # or delay_seconds: 60
data: %{screen: "reminders"}
)
# Cancel a pending notification
Dala.Notify.cancel(socket, "reminder_1")
def handle_info({:notification, %{id: id, data: data, source: :local}}, socket), do: ...Push notifications (requires dala_push package on your server)
# Call once after :notifications permission granted
Dala.Notify.register_push(socket)
def handle_info({:push_token, :ios, token}, socket), do: ...
def handle_info({:push_token, :android, token}, socket), do: ...
def handle_info({:notification, %{title: t, body: b, data: d, source: :push}}, socket), do: ...iOS: UNUserNotificationCenter. Android: NotificationManager + AlarmManager + FCM.
Summary
Functions
Cancel a pending local notification by its id. Has no effect if the notification has already been delivered.
Register this device for push notifications.
Schedule a local notification.
Functions
@spec cancel(Dala.Socket.t(), String.t()) :: Dala.Socket.t()
Cancel a pending local notification by its id. Has no effect if the notification has already been delivered.
@spec register_push(Dala.Socket.t()) :: Dala.Socket.t()
Register this device for push notifications.
The device token arrives as {:push_token, platform, token_string} where
platform is :ios or :android.
Send this token to your server and use the dala_push library to send
notifications to it.
@spec schedule( Dala.Socket.t(), keyword() ) :: Dala.Socket.t()
Schedule a local notification.
Options:
id:(required) — string identifier, used to cancel the notificationtitle:(required) — notification titlebody:(required) — notification body textat: %DateTime{}— absolute trigger time (UTC)delay_seconds: integer— trigger after N seconds (alternative toat:)data: %{}— arbitrary map passed back in thehandle_infopayload