PWA Push Notifications: AI-Generated Code Prompt Example
CODE PREVIEW
Prompt
Create a complete PWA push notification implementation demo. Include: 1) Service worker registration with push event listener, 2) VAPID key generation (use hardcoded for demo), 3) Subscribe/unsubscribe UI with button, 4) Send push notification (simulated via fetch to a mock endpoint or self-contained logic), 5) Offline fallback page. Use clean HTML/CSS/JS, no frameworks. Show notification permission request, subscription state display, and a 'Send Test Notification' button. Style as a modern card UI with glassmorphism.
This prompt is designed for developers who want a self-contained, framework-free demonstration of Progressive Web App push notifications — one of the most effective tools for improving user retention. By requesting a complete implementation that covers service worker registration, VAPID key handling, subscribe/unsubscribe UI, and an offline fallback page, the prompt produces a fully functional reference project you can study, adapt, or present to clients. The glassmorphism card styling ensures the demo looks polished and modern right out of the box.
It works best with capable code-generation models such as GPT-4o or Claude 3.5 Sonnet. Real-world applications include bootstrapping a notification feature for a content site, e-commerce re-engagement flow, or SaaS onboarding reminder. To customize it, swap the hardcoded VAPID keys for your own server-generated pair, point the fetch call at your actual backend endpoint, and adjust the notification copy to match your brand. You can also extend the prompt by asking for a notification scheduling UI or multi-language permission dialogs.
Prompt Overview
This prompt is designed for developers who want a self-contained, framework-free demonstration of Progressive Web App push notifications — one of the most effective tools for improving user retention. By requesting a complete implementation that covers service worker registration, VAPID key handling, subscribe/unsubscribe UI, and an offline fallback page, the prompt produces a fully functional reference project you can study, adapt, or present to clients. The glassmorphism card styling ensures the demo looks polished and modern right out of the box.
It works best with capable code-generation models such as GPT-4o or Claude 3.5 Sonnet. Real-world applications include bootstrapping a notification feature for a content site, e-commerce re-engagement flow, or SaaS onboarding reminder. To customize it, swap the hardcoded VAPID keys for your own server-generated pair, point the fetch call at your actual backend endpoint, and adjust the notification copy to match your brand. You can also extend the prompt by asking for a notification scheduling UI or multi-language permission dialogs.
Was this prompt helpful?
Comments
Comments appear after moderation
この記事が役に立ったら投げ銭で応援
Apple Pay / Google Pay / カード (Visa/Mastercard/JCB/Amex) / Link / Alipay / WeChat Pay 対応 · Stripeで安全に決済
開発者が選ぶ最強ツール集
運営者が毎日使っているツール・ガジェット 6選