Web Push Notifications#
Web Push is a standalone outbound integration, alongside Messenger and SSO. It is not a WebSocket, SSE, or realtime transport: a browser push service can deliver after the page has closed.
Configuration#
TINA4_WEB_PUSH=trueTINA4_VAPID_SUBJECT=mailto:ops@example.comTINA4_VAPID_PUBLIC=your-base64url-public-keyTINA4_VAPID_PRIVATE=your-base64url-private-keyThe private key stays on the server. Setting TINA4_WEB_PUSH=false disables the feature. A configured but incomplete or mismatched key pair fails loudly. Ruby uses its existing OpenSSL stdlib/default gem and adds no JWT or Web Push gem.
Browser subscription#
After registering a service worker, use push.subscribe() from tina4-js with the public VAPID key. Persist the returned endpoint, keys.p256dh, and keys.auth values for the signed-in user.
Server delivery#
sender = Tina4::Push.newresult = sender.send(subscription, { "title" => "Order ready", "body" => "Order 123 is ready for collection"})Tina4::Push.generate_vapid_keys # one-time key generationif result["dead"] # Remove the subscription after HTTP 404 or 410.endDelivery uses OpenSSL for P-256 ECDH, AES-GCM, and VAPID ES256 signing. The result includes ok, status, dead, retryable, endpoint, and the push service response. HTTP 404/410 are dead subscriptions; 408, 429, and 5xx are retryable.