Skip to content

Push Notifications ​

Iris can send proactive messages as native notifications through the browser's Web Push API. When a heartbeat check-in, calendar reminder, or scheduled follow-up fires, a notification pops up on every device you've turned push on for. Iris doesn't need to be open, and you don't need another app.

Push sits alongside Telegram. Each user picks Push, Telegram, both, or neither.

Requirements ​

Browsers only allow Web Push on secure origins, so Iris has to be served over HTTPS. An install on plain HTTP (a LAN IP, for example) can't use push, though localhost works for development.

Current versions of Chrome, Edge, Firefox, and Safari all support it. On iPhone and iPad you need iOS 16.4 or later, and Iris has to be added to the Home Screen, because Safari on iOS only offers push to installed web apps. Open Iris in Safari, tap Share, then Add to Home Screen, and turn push on from the installed app.

How It Works ​

When the heartbeat system generates a proactive message, it fires a HeartbeatMessageEvent. The SendPushNotification listener picks it up and sends a notification to each device the user has subscribed. As with Telegram, the send waits until the heartbeat job finishes, so it never holds up the job.

Each notification shows:

  • The app name as the title
  • The first 200 characters or so of the message as plain text, cut at a word boundary
  • A link to the thread, which opens when you click the notification

NOTE

On iPhone and iPad, a tap only opens the thread when Iris isn't already running. If it's open in the background, iOS brings it forward on whatever page you left it on. This is a WebKit limitation of Home Screen apps, and nothing in the notification changes it. The new thread is at the top of the sidebar.

The message's priority sets the push Urgency header, so a low-priority check-in doesn't wake a phone that's saving battery. If a device is offline, the push service holds the notification for up to 24 hours.

In the installed app, a badge on the icon counts the Iris notifications waiting for you. Opening Iris clears it.

Push payloads are end-to-end encrypted. Apple, Google, and Mozilla deliver them but can't read them.

Push delivery is isolated from everything else. If a push can't be sent, Iris logs it (Push notification delivery failed) and the web UI and Telegram still get the message. If a push service turns a message away, Iris logs a warning (Push notification rejected) with the push service's host, the status code, and the reason. When the push service reports that a subscription is gone (the user cleared site data or uninstalled the app, for example), Iris also deletes it.

Setup ​

1. Generate VAPID Keys ​

VAPID (Voluntary Application Server Identification) keys prove to the push services that notifications really come from your Iris server. Generate them once:

bash
php artisan webpush:vapid

This writes VAPID_PUBLIC_KEY and VAPID_PRIVATE_KEY to your .env.

WARNING

Generate these keys once and keep them. Every subscription is tied to the public key, so regenerating the keys breaks push on every device until each user opens Settings > Notifications on that device and clicks Enable on this device again. Treat the private key like APP_KEY: anyone holding it can send notifications to your users' subscribed devices.

2. Set the Contact Subject (Optional) ​

Push services ask for a contact they can use to reach a server that misbehaves, and Apple rejects pushes without one. Iris uses your APP_URL by default, so no email address gets sent to Apple or Google. To use something else, set an https:// URL or a mailto: address:

bash
VAPID_SUBJECT=mailto:[email protected]

3. Run the Migration ​

bash
php artisan migrate

This creates the push_subscriptions table.

4. Turn It On for a Device ​

  1. Open Iris on the device and go to Settings > Notifications
  2. Click Enable on this device and allow notifications when the browser asks
  3. Click Send Test Notification to check it works end to end. Iris confirms it sent the test, or shows an error if no device's push service accepted it.

Repeat this on each device you want notifications on, up to 20 devices per account. The settings page lists every subscribed device, and you can remove any of them from there. A removed device stops getting notifications until someone clicks Enable on this device on it again.

TIP

On a desktop, installing Iris as an app (the install icon in Chrome or Edge's address bar, or File > Add to Dock in Safari) gives its notifications their own name and icon. Push works in a regular browser tab too.

Shared Devices ​

A push subscription belongs to the browser, not the account. To keep one person's messages off a device someone else uses, Iris removes the device's subscription when you log out from the user menu. After you log back in, turn push on again from Settings > Notifications.

Sessions don't always end through the menu: a session can expire, for example. When a different user signs in on a device that's still subscribed, Iris turns push off for that device, and the new user turns it on for themselves if they want it. If you sign back in as yourself after a session expires, your notifications stay on.

If another user turns on push in a browser you'd subscribed, the subscription moves to their account.

Configuration ​

Push settings live in config/webpush.php:

SettingEnvironment VariableDescription
webpush.vapid.public_keyVAPID_PUBLIC_KEYPublic key, shared with browsers when they subscribe
webpush.vapid.private_keyVAPID_PRIVATE_KEYPrivate key that signs each push
webpush.vapid.subjectVAPID_SUBJECTContact for push services. Defaults to APP_URL

Push is available when both keys are set. Without them, the settings page says push isn't available for this installation and no push notifications are sent.

Troubleshooting ​

The test notification never shows up ​

If Iris said the test was sent, the push service accepted it, so check that your operating system allows notifications from the browser or the installed Iris app. On macOS that's System Settings > Notifications, and Focus modes can hide them too.

If Iris showed an error instead, look for Push notification rejected in your logs: the status code says why. A 403 usually means the VAPID keys changed since the device subscribed. Open Settings > Notifications on that device and click Enable on this device to subscribe it again.

The test button and turning push on are each limited to 6 requests a minute per account.

The page says notifications are blocked ​

You (or the browser) denied permission earlier. Re-enable notifications for your Iris site in the browser's site settings, then reload the page.

The test notification works but heartbeat messages don't push ​

Heartbeat messages go out from your queue workers, and a running worker keeps the configuration it started with. Restart them (php artisan horizon:terminate, or php artisan queue:restart) after setting the VAPID keys.

Notification clicks open the wrong page, or changes to the service worker don't show up ​

Make sure nothing between the browser and Iris caches /service-worker.js. Iris serves it with Cache-Control: no-cache, but a CDN or tunnel with its own cache rules for .js files can still hold an old copy.

It worked on iPhone before and stopped ​

Safari drops subscriptions when Home Screen app data is cleared. Open Iris from the Home Screen and turn push on again.